Skip to content

Commit

Permalink
fix: 🐛 修复和 Soul++ 的兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed Jan 24, 2024
1 parent ac2d582 commit 5ed7d53
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
35 changes: 14 additions & 21 deletions src/helper/triggerLazyLoad.ts
Original file line number Diff line number Diff line change
@@ -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 {
/** 触发次数 */
Expand Down Expand Up @@ -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));
/** 触发翻页 */
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 3 additions & 5 deletions src/site/other.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -24,6 +19,9 @@ import {
throttle,
showPageList,
createEffectOn,
triggerLazyLoad,
needTrigged,
openScrollLock,
} from 'main';

// 测试案例
Expand Down

0 comments on commit 5ed7d53

Please sign in to comment.