{"version":3,"file":"index.CGv_9dU8.js","sources":["../../../../../../src/lib/utils/lazyloader/index.ts"],"sourcesContent":["// See how the options work here: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\nlet options = {\n root: null,\n rootMargin: \"0px\",\n threshold: 0.2\n}\n\nexport const lazyLoader = (image: HTMLImageElement, src: string) => {\n const loaded = () => {\n //image.classList.add('visible') // doesn't work in REPL\n\t\t//image.style.opacity = \"1\" // REPL hack to apply loading animationĀ§\n }\n const observer = new IntersectionObserver(entries => {\n if ((!image.src || image.src==='') && (entries[0].isIntersecting || entries[0].intersectionRatio > 0)) {\n\t\t\t//console.log('image has loaded: ',src); // console log for REPL\n image.src = src; // replace placeholder src with the image src on observe\n if (image.complete) { // check if instantly loaded\n loaded();\n } else {\n image.addEventListener('load', loaded); // if the image isn't loaded yet, add an event listener\n }\n }\n }, options);\n setTimeout(() => observer.disconnect(), 60000); // disconnect after 10 seconds\n image.classList.add('lazyload'); // add lazyload class to image\n observer.observe(image); // intersection observer\n\n return {\n destroy() {\n image.removeEventListener('load', loaded); // clean up the event listener\n }\n }\n}"],"names":["options","lazyLoader","image","src","loaded","observer","entries"],"mappings":"AACA,IAAIA,EAAU,CACV,KAAM,KACN,WAAY,MACZ,UAAW,EACf,EAEa,MAAAC,EAAa,CAACC,EAAyBC,IAAgB,CAChE,MAAMC,EAAS,IAAM,CAGrB,EACMC,EAAW,IAAI,qBAAgCC,GAAA,EAC5C,CAACJ,EAAM,KAAOA,EAAM,MAAM,MAAQI,EAAQ,CAAC,EAAE,gBAAkBA,EAAQ,CAAC,EAAE,kBAAoB,KAE/FJ,EAAM,IAAMC,EACRD,EAAM,UAGAA,EAAA,iBAAiB,OAAQE,CAAM,IAG9CJ,CAAO,EACV,kBAAW,IAAMK,EAAS,WAAW,EAAG,GAAK,EACvCH,EAAA,UAAU,IAAI,UAAU,EAC9BG,EAAS,QAAQH,CAAK,EAEf,CACH,SAAU,CACAA,EAAA,oBAAoB,OAAQE,CAAM,CAAA,CAEhD,CACJ"}