From c91a8baf9cf223342cf964fb3f7cf505ecfa241e Mon Sep 17 00:00:00 2001 From: qq_41923622 Date: Mon, 24 Mar 2025 13:12:00 +0800 Subject: [PATCH] Mon Mar 24 13:12:00 CST 2025 inscode --- index.html | 14 ++------------ src/section/components/imgbox/index.ts | 25 ++++++++++++++++++++++--- src/section/components/index.ts | 3 ++- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index e1350c5..5a7d2a3 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,7 @@
💓 💖
+
@@ -209,18 +210,7 @@
diff --git a/src/section/components/imgbox/index.ts b/src/section/components/imgbox/index.ts index 9242d06..5d8dcb9 100644 --- a/src/section/components/imgbox/index.ts +++ b/src/section/components/imgbox/index.ts @@ -1,4 +1,4 @@ -let imgMap = { +let imgNameMap = { "DSCF7995.jpg": "https://vercel-proxy.fivecc.cn/static-img/1775464/202503/1775464-20250324100029689-1902352921.jpg", "DSCF8019.jpg": "https://vercel-proxy.fivecc.cn/static-img/1775464/202503/1775464-20250324100053386-972327104.jpg", "DSCF8027.jpg": "https://vercel-proxy.fivecc.cn/static-img/1775464/202503/1775464-20250324100058175-827552871.jpg", @@ -36,9 +36,28 @@ let imgMap = { "DSCF8365.jpg": "https://vercel-proxy.fivecc.cn/static-img/1775464/202503/1775464-20250324100709204-1857305680.jpg" } -export function ImgBox(props:any){ + const observer = new IntersectionObserver((entries, observer) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + const img = entry.target; + const realSrc = img.dataset.src; + const imgObj = new Image(); + imgObj.src = realSrc; + imgObj.onload = () => { + img.src = realSrc; + observer.unobserve(img); + }; + } + }); + }); + +export function ImgBox(props:any={}){ + console.log("yyy",this) + let imgSrc = imgNameMap[props.imgName] + let dataSrc = imgNameMap[props.imgName] return { $template:'#imgbox-template', - imgSrc: '' + imgSrc: imgSrc, + dataSrc: dataSrc, } } \ No newline at end of file diff --git a/src/section/components/index.ts b/src/section/components/index.ts index b1875d9..987a1f2 100644 --- a/src/section/components/index.ts +++ b/src/section/components/index.ts @@ -1,8 +1,9 @@ import { CountDown } from "./countdown/index" import { WeddingCalendar } from "./wedding-calendar/index" - +import {ImgBox} from "./imgbox/index" export default { CountDown, WeddingCalendar, + ImgBox, } \ No newline at end of file -- GitLab