hexo-theme-redefine
Version:
Redefine your writing with Hexo Theme Redefine.
2 lines • 758 B
JavaScript
let e=null;export default function initLazyLoad(){"undefined"!=typeof IntersectionObserver?((()=>{if(e)return;if("undefined"==typeof IntersectionObserver)return;e=new IntersectionObserver(((e,t)=>{e.forEach((e=>{if(!e.isIntersecting)return;const r=e.target,a=r.getAttribute("data-src");a&&(r.src=a),r.removeAttribute("lazyload"),delete r.dataset.redefineLazyloadObserved,t.unobserve(r)}))}),{rootMargin:"0px",threshold:.1})})(),e&&document.querySelectorAll("img[lazyload]").forEach((t=>{t.dataset.redefineLazyloadObserved||(t.dataset.redefineLazyloadObserved="true",e.observe(t))}))):document.querySelectorAll("img[lazyload]").forEach((e=>{const t=e.getAttribute("data-src");t&&(e.src=t),e.removeAttribute("lazyload")}))}
//# sourceMappingURL=lazyload.js.map