hexo-theme-fluid icon indicating copy to clipboard operation
hexo-theme-fluid copied to clipboard

修正lazyload有时候失效的问题

Open appotry opened this issue 1 year ago • 3 comments

把element 看做 上下左右加长offsetFactor的箱子来定位 原来的代码看不太明白意义

appotry avatar Apr 21 '24 13:04 appotry

已经切换到dev分支了,还是有个测试报错

appotry avatar Apr 21 '24 14:04 appotry

原本代码中 offsetFactor 是为了提前 N 屏的高度触发 lazyload

你这个实现是达不到之前的效果的

zkqiang avatar Jun 18 '24 09:06 zkqiang

下面代码实现了提前触发的,判断两个盒子是否有重叠,无论放大哪一个盒子都是可行的

const viewportHeight = (window.innerHeight || document.documentElement.clientHeight) * (1 + offsetFactor);
const viewportWidth = (window.innerWidth || document.documentElement.clientWidth) * (1 + offsetFactor);

appotry avatar Jun 20 '24 10:06 appotry