Comparing version 2.0.2 to 2.0.3
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.sponlax=e()}(this,function(){"use strict";function t(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o=function(t){var e=void 0,n=function(n,r){return function(){e=null,t.apply(n,r)}},r=function(){if(null===e||void 0===e){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];e=requestAnimationFrame(n(this,r))}};return r.cancel=function(){return cancelAnimationFrame(e)},r},i=function(){var e=this;this.defaults={rootMargin:"0px",threshold:0,shouldUnObserve:function(){return!1},onEnter:function(){},onLeave:function(){},inview:function(){}},this.update=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.options=r({},e.defaults,o);var i="string"==typeof n?document.querySelectorAll(n):n,a=e.options,s=a.rootMargin,u=a.threshold;e.observer=new IntersectionObserver(e.onIntersection(),{rootMargin:s,threshold:u}),e.nodes=[].concat(t(i)).map(function(t,n){return t.setAttribute("data-sponlax-key",n),e.observer.observe(t),t}),e.elements={}},this.prevFrame=-1,this.within=function(t){return"true"===t.getAttribute("data-inview")},this.disconnect=function(){e.observer&&(e.observer.disconnect(),e.throttled&&e.throttled.cancel())},this.isRunning=!1,this.loop=function(){var t=window.pageYOffset;if(t!==e.prevFrame){e.isRunning=!0;var r=e.prevFrame>t?"up":"down";e.prevFrame=t;var o=e.options.inview;Object.entries(e.elements).forEach(function(e){var i=n(e,2)[1];o(i,r,t)}),e.throttled()}else e.throttled()},this.intersectNode=function(t){var n=e.options,r=n.shouldUnObserve,o=n.onEnter,i=n.onLeave,a=t.target,s=t.isIntersecting,u=a.getAttribute("data-spon-key"),c=a.getAttribute("data-spon-track");a._props=t,s?(r(a)&&e.observer.unobserve(a),c&&(e.elements[u]=a),o(a),!e.within(a)&&a.setAttribute("data-inview","true")):(e.within(a)&&a.setAttribute("data-inview","false"),i(a),c&&delete e.elements[u])},this.onIntersection=function(){return function(t){t.forEach(e.intersectNode),!1===e.isRunning&&(Object.keys(e.elements).length>0?(e.throttled=e.throttled||o(e.loop),e.throttled(),e.isRunning=!0):e.throttled&&(e.throttled.cancel(),e.throttled=null,e.isRunning=!1))}}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,t),i.call(this),this.update(n,r)}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.sponlax=e()}(this,function(){"use strict";function t(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o=function(t){var e=void 0,n=function(n,r){return function(){e=null,t.apply(n,r)}},r=function(){if(null===e||void 0===e){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];e=requestAnimationFrame(n(this,r))}};return r.cancel=function(){return cancelAnimationFrame(e)},r},i=function(){var e=this;this.defaults={rootMargin:"0px",threshold:0,shouldUnObserve:function(){return!1},onEnter:function(){},onLeave:function(){},inview:function(){}},this.update=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.options=r({},e.defaults,o);var i="string"==typeof n?document.querySelectorAll(n):n,a=e.options,s=a.rootMargin,u=a.threshold;e.observer=new IntersectionObserver(e.onIntersection(),{rootMargin:s,threshold:u}),e.nodes=[].concat(t(i)).map(function(t,n){return t.setAttribute("data-sponlax-key",n),e.observer.observe(t),t}),e.elements={}},this.prevFrame=-1,this.within=function(t){return"true"===t.getAttribute("data-inview")},this.disconnect=function(){e.observer&&(e.observer.disconnect(),e.throttled&&e.throttled.cancel())},this.isRunning=!1,this.loop=function(){var t=window.pageYOffset;if(t!==e.prevFrame){e.isRunning=!0;var r=e.prevFrame>t?"up":"down";e.prevFrame=t;var o=e.options.inview;Object.entries(e.elements).forEach(function(e){var i=n(e,2)[1];o(i,r,t)}),e.throttled()}else e.throttled()},this.intersectNode=function(t){var n=e.options,r=n.shouldUnObserve,o=n.onEnter,i=n.onLeave,a=t.target,s=t.isIntersecting,u=a.getAttribute("data-spon-key"),c=a.hasAttribute("data-spon-track");a._props=t,s?(r(a)&&e.observer.unobserve(a),c&&(e.elements[u]=a),o(a),!e.within(a)&&a.setAttribute("data-inview","true")):(e.within(a)&&a.setAttribute("data-inview","false"),i(a),c&&delete e.elements[u])},this.onIntersection=function(){return function(t){t.forEach(e.intersectNode),!1===e.isRunning&&(Object.keys(e.elements).length>0?(e.throttled=e.throttled||o(e.loop),e.throttled(),e.isRunning=!0):e.throttled&&(e.throttled.cancel(),e.throttled=null,e.isRunning=!1))}}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(this,t),i.call(this),this.update(n,r)}}); |
{ | ||
"name": "sponlax", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |