var _extends=Object.assign||function(target){for(var i=1;i=getTopOffset(element)+threshold+element.offsetHeight;};var isAtLeftOfViewport=function isAtLeftOfViewport(element,container,threshold){var fold=container===window?window.pageXOffset:getLeftOffset(container);return fold>=getLeftOffset(element)+threshold+element.offsetWidth;};var isInsideViewport=function isInsideViewport(element,container,threshold){return!isBelowViewport(element,container,threshold)&&!isAboveViewport(element,container,threshold)&&!isAtRightOfViewport(element,container,threshold)&&!isAtLeftOfViewport(element,container,threshold);};var createInstance=function createInstance(classObj,options){var event;var eventString="LazyLoad::Initialized";var instance=new classObj(options);try{event=new CustomEvent(eventString,{detail:{instance:instance}});}catch(err){event=document.createEvent("CustomEvent");event.initCustomEvent(eventString,false,false,{instance:instance});} window.dispatchEvent(event);};var autoInitialize=function autoInitialize(classObj,options){var optsLength=options.length;if(!optsLength){createInstance(classObj,options);}else{for(var i=0;i0){elements.splice(elementsToPurge.pop(),1);}},_startScrollHandler:function _startScrollHandler(){if(!this._isHandlingScroll){this._isHandlingScroll=true;this._settings.container.addEventListener("scroll",this._boundHandleScroll);}},_stopScrollHandler:function _stopScrollHandler(){if(this._isHandlingScroll){this._isHandlingScroll=false;this._settings.container.removeEventListener("scroll",this._boundHandleScroll);}},handleScroll:function handleScroll(){var throttle=this._settings.throttle;if(throttle!==0){var now=Date.now();var remainingTime=throttle-(now-this._previousLoopTime);if(remainingTime<=0||remainingTime>throttle){if(this._loopTimeout){clearTimeout(this._loopTimeout);this._loopTimeout=null;} this._previousLoopTime=now;this._loopThroughElements();}else if(!this._loopTimeout){this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now();this._loopTimeout=null;this._loopThroughElements();}.bind(this),remainingTime);}}else{this._loopThroughElements();}},update:function update(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));this._purgeElements();this._loopThroughElements();this._startScrollHandler();},destroy:function destroy(){window.removeEventListener("resize",this._boundHandleScroll);if(this._loopTimeout){clearTimeout(this._loopTimeout);this._loopTimeout=null;} this._stopScrollHandler();this._elements=null;this._queryOriginNode=null;this._settings=null;}};var autoInitOptions=window.lazyLoadOptions;if(autoInitOptions){autoInitialize(LazyLoad,autoInitOptions);} return LazyLoad;});