1(function($) { 2 var listimgLazy = function ($scope, $) { 3 4 // ================================================== 5 // Image lazy loading 6 // ================================================== 7 8 ScrollTrigger.config({ limitCallbacks: true }); 9 10 gsap.utils.toArray(".tt-lazy").forEach(image => { 11 12 let newSRC = image.dataset.src, 13 newImage = document.createElement("img"), 14 15 loadImage = () => { 16 newImage.onload = () => { 17 newImage.onload = null; // avoid recursion 18 newImage.src = image.src; // swap the src 19 image.src = newSRC; 20 // place the low-res version on TOP and then fade it out. 21 gsap.set(newImage, { 22 position: "absolute", 23 top: image.offsetTop, 24 left: image.offsetLeft, 25 width: image.offsetWidth, 26 height: image.offsetHeight 27 }); 28 image.parentNode.appendChild(newImage); 29 gsap.to(newImage, { 30 opacity: 0, 31 onComplete: () => { 32 newImage.parentNode.removeChild(newImage); 33 image.removeAttribute("data-src"); // remove "data-src" attribute if image is loaded 34 } 35 }); 36 st && st.kill(); 37 } 38 newImage.src = newSRC; 39 40 ScrollTrigger.refresh(true); 41 }, 42 43 st = ScrollTrigger.create({ 44 trigger: image, 45 start: "-50% bottom", 46 onEnter: loadImage, 47 onEnterBack: loadImage // make sure it works in either direction 48 }); 49 }); 50 51 52 }; 53 54 $(window).on('elementor/frontend/init', function () { 55 elementorFrontend.hooks.addAction('frontend/element_ready/nui-portfolio-list.default', listimgLazy); 56 }); 57 58 59})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.