-
Notifications
You must be signed in to change notification settings - Fork 5
/
imagesloader.min.js
1 lines (1 loc) · 2.19 KB
/
imagesloader.min.js
1
LIB.ready((function(e){function t(){LIB.images.lazy(".image-placeholder").on({preload(e,t){const r=!("currentSrc"in e);r?t.insertAdjacentHTML("beforebegin",'<span class=image-placeholder-wrapper><span class=image-placeholder-svg><svg width=100% height=100% version=1.1 xmlns=http://www.w3.org/2000/svg ><image xlink:href="'+(e.currentSrc||e.src)+'" width=100% height=100% filter=url(#blur-lqip) x=0 y=0 />'):t.insertAdjacentHTML("beforebegin","<span class=image-placeholder-wrapper><span class=image-placeholder-opacity><span class=image-placeholder-element style=background-image:url("+(e.currentSrc||e.src)+")>");const n=t.previousElementSibling;if(r){"function"!=typeof window.CustomEvent&&window.Event.prototype;const t=n.querySelector("svg");function s(){const e=this.height,r=this.width;t.setAttribute("height",e),t.setAttribute("width",r)}e.addEventListener("sourcechange",s),e.addEventListener("load",s)}t.classList.remove("image-placeholder","image-placeholder-lqip","image-placeholder-svg"),n.insertBefore(t,n.firstElementChild)},load:r,error(e,t,n){r(0,n)}})}function r(e,t){t.dataset.src&&(t.src=t.dataset.src),t.dataset.srcset&&(t.srcset=t.dataset.srcset),setTimeout((function(){let e=t;for(t.removeAttribute("data-srcset"),t.removeAttribute("data-src"),t.classList.add("image-placeholder-complete");e instanceof HTMLElement&&!e.classList.contains("image-placeholder-wrapper");)e=e.parentElement;e&&e.parentElement.insertBefore(t,e),setTimeout((function(){t.classList.remove("image-placeholder-complete"),e&&e.parentElement.removeChild(e)}),5)}),5)}if("srcset"in new Image||document.body.insertAdjacentHTML("beforeend","<svg xmlns=http://www.w3.org/2000/svg width=1 height=1><defs><filter id=blur-lqip width=100% height=100% ><feGaussianBlur stdDeviation=20 /></filter></defs></svg>"),"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"intersectionRatio"in IntersectionObserverEntry.prototype)"isIntersecting"in IntersectionObserverEntry.prototype||Object.defineProperty(IntersectionObserverEntry.prototype,"isIntersecting",{get:function(){return this.intersectionRatio>0}}),t();else{const e=document.createElement("script");e.onload=t,e.defer=!0,e.async=!0,e.src="{script-src}",document.body.appendChild(e)}}));