Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.sponlax=n()}(this,function(){"use strict";function e(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function n(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o=function(){var n=this;this.defaults={rootMargin:"0px",threshold:0,shouldUnObserve:function(){return!1},onEnter:function(){},onLeave:function(){},inview:function(){}},this.prevFrame=-1,this.within=function(e){return"true"===e.getAttribute("data-inview")},this.disconnect=function(){n.observer&&(n.elements.clear(),n.observer.disconnect(),cancelAnimationFrame(n.handle))},this.update=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n.options=t({},n.defaults,r);var i=n.options,a=i.rootMargin,s=i.threshold;n.observer=new IntersectionObserver(n.onIntersection(),{rootMargin:a,threshold:s}),n.nodes=[].concat(e(document.querySelectorAll(o))).map(function(e){return n.observer.observe(e),e}),n.elements=new Set,n.handle=null},this.loop=function(){if(window.pageYOffset!==n.prevFrame){n.prevFrame=window.pageYOffset;var t=n.options.inview;[].concat(e(n.elements)).forEach(t),n.handle=requestAnimationFrame(n.loop)}else n.handle=requestAnimationFrame(n.loop)},this.onIntersection=function(){return function(e,t){var o=n.options,r=o.shouldUnObserve,i=o.onEnter,a=o.onLeave;e.forEach(function(e){var o=e.target;e.isIntersecting?(r(o)&&t.unobserve(o),o._props=e,n.elements.add(o),i(o),!n.within(o)&&o.setAttribute("data-inview","true")):(n.within(o)&&o.setAttribute("data-inview","false"),a(o),n.elements.delete(o))}),n.elements.size>0&&null===n.handle&&n.loop(),0===n.elements.length&&(cancelAnimationFrame(n.handle),n.handle=null)}}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e),o.call(this),this.update(t,r)}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.sponlax=n()}(this,function(){"use strict";function e(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}function n(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o=function(){var n=this;this.defaults={rootMargin:"0px",threshold:0,shouldUnObserve:function(){return!1},onEnter:function(){},onLeave:function(){},inview:function(){}},this.prevFrame=-1,this.within=function(e){return"true"===e.getAttribute("data-inview")},this.disconnect=function(){n.observer&&(n.elements.clear(),n.observer.disconnect(),cancelAnimationFrame(n.handle))},this.update=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n.options=t({},n.defaults,r);var i=n.options,a=i.rootMargin,s=i.threshold;n.observer=new IntersectionObserver(n.onIntersection(),{rootMargin:a,threshold:s}),n.nodes=[].concat(e(document.querySelectorAll(o))).map(function(e){return n.observer.observe(e),e}),n.elements=new Set,n.handle=null},this.loop=function(){if(window.pageYOffset!==n.prevFrame){var t=n.prevFrame>window.pageYOffset?"up":"down";n.prevFrame=window.pageYOffset;var o=n.options.inview;[].concat(e(n.elements)).forEach(function(e){o(e,t)}),n.handle=requestAnimationFrame(n.loop)}else n.handle=requestAnimationFrame(n.loop)},this.onIntersection=function(){return function(e,t){var o=n.options,r=o.shouldUnObserve,i=o.onEnter,a=o.onLeave;e.forEach(function(e){var o=e.target;e.isIntersecting?(r(o)&&t.unobserve(o),o._props=e,n.elements.add(o),i(o),!n.within(o)&&o.setAttribute("data-inview","true")):(n.within(o)&&o.setAttribute("data-inview","false"),a(o),n.elements.delete(o))}),n.elements.size>0&&null===n.handle&&n.loop(),0===n.elements.length&&(cancelAnimationFrame(n.handle),n.handle=null)}}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,e),o.call(this),this.update(t,r)}}); |
{ | ||
"name": "sponlax", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "dist/index.min.js", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4977
10