vanilla-lazyload
Advanced tools
Comparing version 6.3.0 to 6.3.1
@@ -1,2 +0,2 @@ | ||
!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.LazyLoad=b()}(window,function(){const a=!("onscroll"in window)||/glebot/.test(navigator.userAgent),b=function(a){return a.getBoundingClientRect().top+window.pageYOffset-a.ownerDocument.documentElement.clientTop},c=function(a,c,d){return(c===window?window.innerHeight+window.pageYOffset:b(c)+c.offsetHeight)<=b(a)-d},d=function(a){return a.getBoundingClientRect().left+window.pageXOffset-a.ownerDocument.documentElement.clientLeft},e=function(a,b,c){const e=window.innerWidth;return(b===window?e+window.pageXOffset:d(b)+e)<=d(a)-c},f=function(a,c,d){return(c===window?window.pageYOffset:b(c))>=b(a)+d+a.offsetHeight},g=function(a,b,c){return(b===window?window.pageXOffset:d(b))>=d(a)+c+a.offsetWidth},h=function(a,b,d){return!(c(a,b,d)||f(a,b,d)||e(a,b,d)||g(a,b,d))},i=function(a,b){a&&a(b)},j=function(a){let b=new l(a),c=new CustomEvent("LazyLoad::Initialized",{detail:{instance:b}});window.dispatchEvent(c)},k={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",class_error:"error",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null};class l{constructor(a){this._settings=Object.assign({},k,a),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),window.addEventListener("resize",this._boundHandleScroll),this.update()}_setSourcesForPicture(a,b){const c=a.parentElement;if("PICTURE"===c.tagName)for(let a=0;a<c.children.length;a++){let d=c.children[a];if("SOURCE"===d.tagName){let a=d.getAttribute("data-"+b);a&&d.setAttribute("srcset",a)}}}_setSources(a,b,c){const d=a.tagName,e=a.getAttribute("data-"+c);if("IMG"===d){this._setSourcesForPicture(a,b);const c=a.getAttribute("data-"+b);return c&&a.setAttribute("srcset",c),void(e&&a.setAttribute("src",e))}if("IFRAME"===d)return void(e&&a.setAttribute("src",e));e&&(a.style.backgroundImage="url("+e+")")}_showOnAppear(a){const b=this._settings,c=function(){b&&(a.removeEventListener("load",d),a.removeEventListener("error",c),a.classList.remove(b.class_loading),a.classList.add(b.class_error),i(b.callback_error,a))},d=function(){b&&(a.classList.remove(b.class_loading),a.classList.add(b.class_loaded),a.removeEventListener("load",d),a.removeEventListener("error",c),i(b.callback_load,a))};"IMG"!==a.tagName&&"IFRAME"!==a.tagName||(a.addEventListener("load",d),a.addEventListener("error",c),a.classList.add(b.class_loading)),this._setSources(a,b.data_srcset,b.data_src),i(b.callback_set,a)}_loopThroughElements(){const b=this._settings,c=this._elements,d=c?c.length:0;let e,f=[];for(e=0;e<d;e++){let d=c[e];b.skip_invisible&&null===d.offsetParent||(a||h(d,b.container,b.threshold))&&(this._showOnAppear(d),f.push(e),d.wasProcessed=!0)}for(;f.length>0;)c.splice(f.pop(),1),i(b.callback_processed,c.length);0===d&&this._stopScrollHandler()}_purgeElements(){const a=this._elements,b=a.length;let c,d=[];for(c=0;c<b;c++){let b=a[c];b.wasProcessed&&d.push(c)}for(;d.length>0;)a.splice(d.pop(),1)}_startScrollHandler(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))}_stopScrollHandler(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))}handleScroll(){const a=this._settings.throttle;if(0!==a){const b=()=>{(new Date).getTime()};let c=b(),d=a-(c-this._previousLoopTime);d<=0||d>a?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=c,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=b(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),d))}else this._loopThroughElements()}update(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()}destroy(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}}let m=window.lazyLoadOptions;return m&&function(a){let b=a.length;if(b)for(let c=0;c<b;c++)j(a[c]);else j(a)}(m),l}); | ||
!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.LazyLoad=b()}(window,function(){const a=!("onscroll"in window)||/glebot/.test(navigator.userAgent),b=function(a){return a.getBoundingClientRect().top+window.pageYOffset-a.ownerDocument.documentElement.clientTop},c=function(a,c,d){return(c===window?window.innerHeight+window.pageYOffset:b(c)+c.offsetHeight)<=b(a)-d},d=function(a){return a.getBoundingClientRect().left+window.pageXOffset-a.ownerDocument.documentElement.clientLeft},e=function(a,b,c){const e=window.innerWidth;return(b===window?e+window.pageXOffset:d(b)+e)<=d(a)-c},f=function(a,c,d){return(c===window?window.pageYOffset:b(c))>=b(a)+d+a.offsetHeight},g=function(a,b,c){return(b===window?window.pageXOffset:d(b))>=d(a)+c+a.offsetWidth},h=function(a,b,d){return!(c(a,b,d)||f(a,b,d)||e(a,b,d)||g(a,b,d))},i=function(a,b){a&&a(b)},j=function(a){let b=new l(a),c=new CustomEvent("LazyLoad::Initialized",{detail:{instance:b}});window.dispatchEvent(c)},k={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null};class l{constructor(a){this._settings=Object.assign({},k,a),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()}_setSourcesForPicture(a,b){const c=a.parentElement;if("PICTURE"===c.tagName)for(let a=0;a<c.children.length;a++){let d=c.children[a];if("SOURCE"===d.tagName){let a=d.getAttribute("data-"+b);a&&d.setAttribute("srcset",a)}}}_setSources(a,b,c){const d=a.tagName,e=a.getAttribute("data-"+c);if("IMG"===d){this._setSourcesForPicture(a,b);const c=a.getAttribute("data-"+b);return c&&a.setAttribute("srcset",c),void(e&&a.setAttribute("src",e))}if("IFRAME"===d)return void(e&&a.setAttribute("src",e));e&&(a.style.backgroundImage="url("+e+")")}_showOnAppear(a){const b=this._settings,c=function(){b&&(a.removeEventListener("load",d),a.removeEventListener("error",c),a.classList.remove(b.class_loading),a.classList.add(b.class_error),i(b.callback_error,a))},d=function(){b&&(a.classList.remove(b.class_loading),a.classList.add(b.class_loaded),a.removeEventListener("load",d),a.removeEventListener("error",c),i(b.callback_load,a))};"IMG"!==a.tagName&&"IFRAME"!==a.tagName||(a.addEventListener("load",d),a.addEventListener("error",c),a.classList.add(b.class_loading)),this._setSources(a,b.data_srcset,b.data_src),i(b.callback_set,a)}_loopThroughElements(){const b=this._settings,c=this._elements,d=c?c.length:0;let e,f=[],g=this._isFirstLoop;for(e=0;e<d;e++){let d=c[e];b.skip_invisible&&null===d.offsetParent||(a||h(d,b.container,b.threshold))&&(g&&d.classList.add(b.class_initial),this._showOnAppear(d),f.push(e),d.wasProcessed=!0)}for(;f.length>0;)c.splice(f.pop(),1),i(b.callback_processed,c.length);0===d&&this._stopScrollHandler(),g&&(this._isFirstLoop=!1)}_purgeElements(){const a=this._elements,b=a.length;let c,d=[];for(c=0;c<b;c++){let b=a[c];b.wasProcessed&&d.push(c)}for(;d.length>0;)a.splice(d.pop(),1)}_startScrollHandler(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))}_stopScrollHandler(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))}handleScroll(){const a=this._settings.throttle;if(0!==a){const b=()=>{(new Date).getTime()};let c=b(),d=a-(c-this._previousLoopTime);d<=0||d>a?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=c,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=b(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),d))}else this._loopThroughElements()}update(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()}destroy(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}}let m=window.lazyLoadOptions;return m&&function(a){let b=a.length;if(b)for(let c=0;c<b;c++)j(a[c]);else j(a)}(m),l}); | ||
//# sourceMappingURL=lazyload.min.js.map |
@@ -94,2 +94,3 @@ 'use strict'; | ||
class_error: "error", | ||
class_initial: "initial", | ||
skip_invisible: true, | ||
@@ -113,2 +114,3 @@ callback_load: null, | ||
this._isFirstLoop = true; | ||
window.addEventListener("resize", this._boundHandleScroll); | ||
@@ -200,3 +202,4 @@ this.update(); | ||
var i = void 0, | ||
processedIndexes = []; | ||
processedIndexes = [], | ||
firstLoop = this._isFirstLoop; | ||
@@ -211,4 +214,7 @@ for (i = 0; i < elementsLength; i++) { | ||
if (_isBot || _isInsideViewport(element, settings.container, settings.threshold)) { | ||
if (firstLoop) { | ||
element.classList.add(settings.class_initial); | ||
} | ||
/* Start loading the image */ | ||
this._showOnAppear(element); | ||
/* Marking the element as processed. */ | ||
@@ -229,2 +235,6 @@ processedIndexes.push(i); | ||
} | ||
/* Sets isFirstLoop to false */ | ||
if (firstLoop) { | ||
this._isFirstLoop = false; | ||
} | ||
} | ||
@@ -231,0 +241,0 @@ }, { |
@@ -1,2 +0,2 @@ | ||
"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _extends=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=b():a.LazyLoad=b()}(window,function(){var a=!("onscroll"in window)||/glebot/.test(navigator.userAgent),b=function(a){return a.getBoundingClientRect().top+window.pageYOffset-a.ownerDocument.documentElement.clientTop},c=function(a,c,d){return(c===window?window.innerHeight+window.pageYOffset:b(c)+c.offsetHeight)<=b(a)-d},d=function(a){return a.getBoundingClientRect().left+window.pageXOffset-a.ownerDocument.documentElement.clientLeft},e=function(a,b,c){var e=window.innerWidth;return(b===window?e+window.pageXOffset:d(b)+e)<=d(a)-c},f=function(a,c,d){return(c===window?window.pageYOffset:b(c))>=b(a)+d+a.offsetHeight},g=function(a,b,c){return(b===window?window.pageXOffset:d(b))>=d(a)+c+a.offsetWidth},h=function(a,b,d){return!(c(a,b,d)||f(a,b,d)||e(a,b,d)||g(a,b,d))},i=function(a,b){a&&a(b)},j=function(a){var b=new l(a),c=new CustomEvent("LazyLoad::Initialized",{detail:{instance:b}});window.dispatchEvent(c)},k={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",class_error:"error",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null},l=function(){function b(a){_classCallCheck(this,b),this._settings=_extends({},k,a),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),window.addEventListener("resize",this._boundHandleScroll),this.update()}return _createClass(b,[{key:"_setSourcesForPicture",value:function(a,b){var c=a.parentElement;if("PICTURE"===c.tagName)for(var d=0;d<c.children.length;d++){var e=c.children[d];if("SOURCE"===e.tagName){var f=e.getAttribute("data-"+b);f&&e.setAttribute("srcset",f)}}}},{key:"_setSources",value:function(a,b,c){var d=a.tagName,e=a.getAttribute("data-"+c);if("IMG"===d){this._setSourcesForPicture(a,b);var f=a.getAttribute("data-"+b);return f&&a.setAttribute("srcset",f),void(e&&a.setAttribute("src",e))}if("IFRAME"===d)return void(e&&a.setAttribute("src",e));e&&(a.style.backgroundImage="url("+e+")")}},{key:"_showOnAppear",value:function(a){var b=this._settings,c=function c(){b&&(a.removeEventListener("load",d),a.removeEventListener("error",c),a.classList.remove(b.class_loading),a.classList.add(b.class_error),i(b.callback_error,a))},d=function d(){b&&(a.classList.remove(b.class_loading),a.classList.add(b.class_loaded),a.removeEventListener("load",d),a.removeEventListener("error",c),i(b.callback_load,a))};"IMG"!==a.tagName&&"IFRAME"!==a.tagName||(a.addEventListener("load",d),a.addEventListener("error",c),a.classList.add(b.class_loading)),this._setSources(a,b.data_srcset,b.data_src),i(b.callback_set,a)}},{key:"_loopThroughElements",value:function(){var b=this._settings,c=this._elements,d=c?c.length:0,e=void 0,f=[];for(e=0;e<d;e++){var g=c[e];b.skip_invisible&&null===g.offsetParent||(a||h(g,b.container,b.threshold))&&(this._showOnAppear(g),f.push(e),g.wasProcessed=!0)}for(;f.length>0;)c.splice(f.pop(),1),i(b.callback_processed,c.length);0===d&&this._stopScrollHandler()}},{key:"_purgeElements",value:function(){var a=this._elements,b=a.length,c=void 0,d=[];for(c=0;c<b;c++){a[c].wasProcessed&&d.push(c)}for(;d.length>0;)a.splice(d.pop(),1)}},{key:"_startScrollHandler",value:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))}},{key:"_stopScrollHandler",value:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))}},{key:"handleScroll",value:function(){var a=this,b=this._settings.throttle;0!==b?function(){var c=function(){(new Date).getTime()},d=c(),e=b-(d-a._previousLoopTime);e<=0||e>b?(a._loopTimeout&&(clearTimeout(a._loopTimeout),a._loopTimeout=null),a._previousLoopTime=d,a._loopThroughElements()):a._loopTimeout||(a._loopTimeout=setTimeout(function(){this._previousLoopTime=c(),this._loopTimeout=null,this._loopThroughElements()}.bind(a),e))}():this._loopThroughElements()}},{key:"update",value:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()}},{key:"destroy",value:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}}]),b}(),m=window.lazyLoadOptions;return m&&function(a){var b=a.length;if(b)for(var c=0;c<b;c++)j(a[c]);else j(a)}(m),l}); | ||
"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var _extends=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=b():a.LazyLoad=b()}(window,function(){var a=!("onscroll"in window)||/glebot/.test(navigator.userAgent),b=function(a){return a.getBoundingClientRect().top+window.pageYOffset-a.ownerDocument.documentElement.clientTop},c=function(a,c,d){return(c===window?window.innerHeight+window.pageYOffset:b(c)+c.offsetHeight)<=b(a)-d},d=function(a){return a.getBoundingClientRect().left+window.pageXOffset-a.ownerDocument.documentElement.clientLeft},e=function(a,b,c){var e=window.innerWidth;return(b===window?e+window.pageXOffset:d(b)+e)<=d(a)-c},f=function(a,c,d){return(c===window?window.pageYOffset:b(c))>=b(a)+d+a.offsetHeight},g=function(a,b,c){return(b===window?window.pageXOffset:d(b))>=d(a)+c+a.offsetWidth},h=function(a,b,d){return!(c(a,b,d)||f(a,b,d)||e(a,b,d)||g(a,b,d))},i=function(a,b){a&&a(b)},j=function(a){var b=new l(a),c=new CustomEvent("LazyLoad::Initialized",{detail:{instance:b}});window.dispatchEvent(c)},k={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"original",data_srcset:"original-set",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null},l=function(){function b(a){_classCallCheck(this,b),this._settings=_extends({},k,a),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()}return _createClass(b,[{key:"_setSourcesForPicture",value:function(a,b){var c=a.parentElement;if("PICTURE"===c.tagName)for(var d=0;d<c.children.length;d++){var e=c.children[d];if("SOURCE"===e.tagName){var f=e.getAttribute("data-"+b);f&&e.setAttribute("srcset",f)}}}},{key:"_setSources",value:function(a,b,c){var d=a.tagName,e=a.getAttribute("data-"+c);if("IMG"===d){this._setSourcesForPicture(a,b);var f=a.getAttribute("data-"+b);return f&&a.setAttribute("srcset",f),void(e&&a.setAttribute("src",e))}if("IFRAME"===d)return void(e&&a.setAttribute("src",e));e&&(a.style.backgroundImage="url("+e+")")}},{key:"_showOnAppear",value:function(a){var b=this._settings,c=function c(){b&&(a.removeEventListener("load",d),a.removeEventListener("error",c),a.classList.remove(b.class_loading),a.classList.add(b.class_error),i(b.callback_error,a))},d=function d(){b&&(a.classList.remove(b.class_loading),a.classList.add(b.class_loaded),a.removeEventListener("load",d),a.removeEventListener("error",c),i(b.callback_load,a))};"IMG"!==a.tagName&&"IFRAME"!==a.tagName||(a.addEventListener("load",d),a.addEventListener("error",c),a.classList.add(b.class_loading)),this._setSources(a,b.data_srcset,b.data_src),i(b.callback_set,a)}},{key:"_loopThroughElements",value:function(){var b=this._settings,c=this._elements,d=c?c.length:0,e=void 0,f=[],g=this._isFirstLoop;for(e=0;e<d;e++){var j=c[e];b.skip_invisible&&null===j.offsetParent||(a||h(j,b.container,b.threshold))&&(g&&j.classList.add(b.class_initial),this._showOnAppear(j),f.push(e),j.wasProcessed=!0)}for(;f.length>0;)c.splice(f.pop(),1),i(b.callback_processed,c.length);0===d&&this._stopScrollHandler(),g&&(this._isFirstLoop=!1)}},{key:"_purgeElements",value:function(){var a=this._elements,b=a.length,c=void 0,d=[];for(c=0;c<b;c++){a[c].wasProcessed&&d.push(c)}for(;d.length>0;)a.splice(d.pop(),1)}},{key:"_startScrollHandler",value:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))}},{key:"_stopScrollHandler",value:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))}},{key:"handleScroll",value:function(){var a=this,b=this._settings.throttle;0!==b?function(){var c=function(){(new Date).getTime()},d=c(),e=b-(d-a._previousLoopTime);e<=0||e>b?(a._loopTimeout&&(clearTimeout(a._loopTimeout),a._loopTimeout=null),a._previousLoopTime=d,a._loopThroughElements()):a._loopTimeout||(a._loopTimeout=setTimeout(function(){this._previousLoopTime=c(),this._loopTimeout=null,this._loopThroughElements()}.bind(a),e))}():this._loopThroughElements()}},{key:"update",value:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()}},{key:"destroy",value:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}}]),b}(),m=window.lazyLoadOptions;return m&&function(a){var b=a.length;if(b)for(var c=0;c<b;c++)j(a[c]);else j(a)}(m),l}); | ||
//# sourceMappingURL=lazyload.transpiled.min.js.map |
{ | ||
"name": "vanilla-lazyload", | ||
"version": "6.3.0", | ||
"version": "6.3.1", | ||
"description": "A fast, lightweight script to load images as they enter the viewport. SEO friendly, it supports responsive images (both srcset + sizes and picture) and progressive JPEG", | ||
@@ -5,0 +5,0 @@ "main": "dist/lazyload.transpiled.min.js", |
@@ -195,2 +195,3 @@ # LazyLoad (aka Vanilla LazyLoad) | ||
| `class_error` | The class applied to the elements (`img` or `iframe`) when the element causes an error | `"error"` | | ||
| `class_initial` | The class applied to the first batch elements (`img` or `iframe`) to be loaded in the page | `"initial"` | | ||
| `skip_invisible` | Specifies whether the script has to consider invisible images or not | `true` | | ||
@@ -286,5 +287,5 @@ | `callback_load` | A function to be called when an element (`img` or `iframe`) was loaded. | `null` | | ||
#### Fade-in demo | ||
#### Fade-in + initial demo | ||
This demo shows how to use LazyLoad to fade-in loaded images as they load. | ||
This demo shows how to use LazyLoad to fade-in loaded images as they load, except the initial batch of images. | ||
@@ -291,0 +292,0 @@ [See it in action](http://verlok.github.io/lazyload/demos/fade_in.html) | [View source](https://github.com/verlok/lazyload/blob/master/demos/fade_in.html) |
@@ -90,2 +90,3 @@ (function (root, factory) { | ||
class_error: "error", | ||
class_initial: "initial", | ||
skip_invisible: true, | ||
@@ -102,3 +103,3 @@ callback_load: null, | ||
this._queryOriginNode = this._settings.container === window ? document : this._settings.container; | ||
this._previousLoopTime = 0; | ||
@@ -108,2 +109,3 @@ this._loopTimeout = null; | ||
this._isFirstLoop = true; | ||
window.addEventListener("resize", this._boundHandleScroll); | ||
@@ -186,3 +188,4 @@ this.update(); | ||
let i, | ||
processedIndexes = []; | ||
processedIndexes = [], | ||
firstLoop = this._isFirstLoop; | ||
@@ -195,6 +198,9 @@ for (i = 0; i < elementsLength; i++) { | ||
} | ||
if (_isBot || _isInsideViewport(element, settings.container, settings.threshold)) { | ||
if (firstLoop) { | ||
element.classList.add(settings.class_initial); | ||
} | ||
/* Start loading the image */ | ||
this._showOnAppear(element); | ||
/* Marking the element as processed. */ | ||
@@ -215,2 +221,6 @@ processedIndexes.push(i); | ||
} | ||
/* Sets isFirstLoop to false */ | ||
if (firstLoop) { | ||
this._isFirstLoop = false; | ||
} | ||
} | ||
@@ -217,0 +227,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
921183
995
329