From 5ed7d530942db8a2243878aa889d8cc426c5f830 Mon Sep 17 00:00:00 2001 From: hymbz Date: Wed, 24 Jan 2024 14:53:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E5=A4=8D=E5=92=8C=20So?= =?UTF-8?q?ul++=20=E7=9A=84=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://south-plus.org/read.php?tid=2036208 --- src/helper/triggerLazyLoad.ts | 35 ++++++++++++++--------------------- src/main.ts | 1 + src/site/other.ts | 8 +++----- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/helper/triggerLazyLoad.ts b/src/helper/triggerLazyLoad.ts index 3e423e22..eb4b7db4 100644 --- a/src/helper/triggerLazyLoad.ts +++ b/src/helper/triggerLazyLoad.ts @@ -1,11 +1,5 @@ import { createScheduled } from '@solid-primitives/scheduled'; -import { - singleThreaded, - triggerEleLazyLoad, - wait, - throttle, - sleep, -} from 'main'; +import { singleThreaded, triggerEleLazyLoad, wait, throttle, sleep } from '.'; interface ImgData { /** 触发次数 */ @@ -105,20 +99,19 @@ const handleTrigged = (e: HTMLImageElement) => { }; /** 监视图片是否被显示的 Observer */ -imgShowObserver = new IntersectionObserver((entries) => - entries.forEach((img) => { - const ele = img.target as HTMLImageElement; - if (img.isIntersecting) { - imgMap.set(ele, { - ...getImg(ele), - observerTimeout: window.setTimeout(handleTrigged, 290, ele), - }); - } - - const timeoutID = imgMap.get(ele)?.observerTimeout; - if (timeoutID) window.clearTimeout(timeoutID); - }), -); +// imgShowObserver = new IntersectionObserver((entries) => +// entries.forEach((img) => { +// // const ele = img.target as HTMLImageElement; +// // if (img.isIntersecting) { +// // imgMap.set(ele, { +// // ...getImg(ele), +// // observerTimeout: window.setTimeout(handleTrigged, 290, ele), +// // }); +// // } +// // const timeoutID = imgMap.get(ele)?.observerTimeout; +// // if (timeoutID) window.clearTimeout(timeoutID); +// }), +// ); const turnPageScheduled = createScheduled((fn) => throttle(fn, 1000)); /** 触发翻页 */ diff --git a/src/main.ts b/src/main.ts index 0db4b8a0..1ec13c30 100644 --- a/src/main.ts +++ b/src/main.ts @@ -18,6 +18,7 @@ export * from './helper/universalInit'; export * from './helper/other'; export * from './helper/detectAd'; export * from './helper/solidJs'; +export * from './helper/triggerLazyLoad'; export * from './components/useComponents/Fab'; export * from './components/useComponents/Manga'; export * from './components/useComponents/Toast'; diff --git a/src/site/other.ts b/src/site/other.ts index aa071727..ee96f986 100644 --- a/src/site/other.ts +++ b/src/site/other.ts @@ -1,11 +1,6 @@ // 这个文件里不能含有 jsx 代码,否则会在打包时自动加入 import solidjs 的代码 import { getInitLang } from 'helper/languages'; -import { - triggerLazyLoad, - needTrigged, - openScrollLock, -} from 'helper/triggerLazyLoad'; import { getEleSelector, isEleSelector } from 'helper/eleSelector'; import { t, @@ -24,6 +19,9 @@ import { throttle, showPageList, createEffectOn, + triggerLazyLoad, + needTrigged, + openScrollLock, } from 'main'; // 测试案例