1 2 3$.fn.scrollLoading = function (options) { 4 5 let images = $(this); 6 7 images.each(function () { 8 if( typeof DNNapplyTypography == "undefined" && this.nodeName.toLowerCase() == "img" ){ 9 let url = $(this).attr("data-src"); 10 var viewBox =$(this).attr("src") && $(this).attr("src").indexOf("viewBox='")!=-1? $(this).attr("src").split("viewBox='")[1].split("' ")[0].split(" "):false; 11 if(viewBox[2]){ 12 var w= viewBox[2]; 13 }else{ 14 var w= $(this).width(); 15 } 16 17 if(url && (url.indexOf(".png")!= -1 || url.indexOf(".gif")!= -1)){ 18 $(this).before('<span class="Lazy-loading-transparent" style="width:'+w+'px"></span>').parent().addClass("img-Lazy-warp"); 19 }else if(url){ 20 $(this).before('<span class="Lazy-loading" style="width:'+w+'px"></span>').parent().addClass("img-Lazy-warp"); 21 } 22 } 23 }); 24 25 function imgAnimation(o){ 26 o.siblings(".Lazy-loading,.Lazy-loading-transparent").addClass("load-over").delay(400).queue(function(){$(this).remove().dequeue();}); 27 o.removeClass("Lazy-loading"); 28 } 29 30 if(typeof IntersectionObserver == "function"){ 31 let observer = new IntersectionObserver( function(entries) { 32 entries.forEach(function(entry) { 33 if (entry.intersectionRatio > 0 && entry.intersectionRatio <= 1) { 34 if(entry.target.dataset.src){ 35 entry.target.src = entry.target.dataset.src; 36 $(entry.target).one("load", function () { 37 imgAnimation($(entry.target)); 38 }) 39 } 40 observer.unobserve(entry.target); 41 } 42 }) 43 },{threshold :[0, 0.25,1]}) 44 images.each(function(){ 45 observer.observe(this); 46 }) 47 48 }else{ 49 50 var defaults = { 51 attr: "data-src", 52 container: window, 53 loading: false, 54 callback: $.noop 55 }; 56 var params = $.extend({}, defaults, options || {}); 57 var container = $(params.container); 58 let images = $(this); 59 params.cache = []; 60 images.each(function () { 61 var node = this.nodeName.toLowerCase(), 62 url = $(this).attr(params["attr"]); 63 var data = { 64 obj: $(this), 65 tag: node, 66 url: url 67 }; 68 69 params.cache.push(data); 70 }); 71 72 var callback = function (call) { 73 if ($.isFunction(params.callback)) { 74 params.callback.call(call); 75 } 76 }; 77 var loading = function () { 78 var contHeight = container.outerHeight(); 79 var contWidth = container.outerWidth(); 80 if (container.get(0) === window) { 81 var contop = $(window).scrollTop(); 82 var conleft = $(window).scrollLeft(); 83 } else { 84 var contop = container.offset().top; 85 var conleft = container.offset().left; 86 } 87 $.each(params.cache, function (i, data) { 88 var o = data.obj, 89 tag = data.tag, 90 url = data.url, 91 post, posb, posl, posr; 92 if (o) { 93 post = o.offset().top - (contop + contHeight); 94 posb = o.offset().top + o.height() - contop; 95 posl = o.offset().left - (conleft + contWidth); 96 posr = o.offset().left + o.width() - conleft; 97 if (o.is(':visible') && (post < 0 && posb > 0) && (posl < 0 && posr > 0)) { 98 if (url) { 99 if (tag === "img" ) { 100 callback(o.attr("src", url)); 101 if (params.loading) { 102 o.one("load", function () { 103 imgAnimation(o); 104 }) 105 } else { 106 o.one("load", function () { 107 imgAnimation(o); 108 }) 109 } 110 }else if (tag === "iframe") { 111 callback(o.attr("src", url)); 112 o.one("load", function () { 113 o.removeClass("Lazy-loading"); 114 }) 115 } else { 116 callback(o.css("background-image", "url(" + url + ")")); 117 imgAnimation(o); 118 } 119 } else { 120 callback(o); 121 imgAnimation(o); 122 } 123 data.obj = null; 124 } 125 } 126 }); 127 }; 128 loading(); 129 container.on("scroll", loading); 130 } 131}; 132 133jQuery(document).ready(function () { 134 $(".img-Lazy").scrollLoading({ 135 loading: true, 136 });
137 $(".iframe-Lazy").scrollLoading({ 138 loading: true, 139 }); 140}) 141 142
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.