Comparing version 0.2.0 to 1.0.0
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.sponlax=n()}(this,function(){"use strict";function t(t){if(Array.isArray(t)){for(var n=0,e=Array(t.length);n<t.length;n++)e[n]=t[n];return e}return Array.from(t)}function n(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},i=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(t){return"true"===t.getAttribute("data-inview")},this.markAsWithin=function(t){return t.setAttribute("data-inview","true")},this.markAsNotWithin=function(t){return t.setAttribute("data-inview","false")},this.loop=function(){if(n.y!==n.prevFrame){n.prevFrame=n.y;var e=n.options.inview;[].concat(t(n.blobs)).forEach(e),n.handle=requestAnimationFrame(n.loop)}else n.handle=requestAnimationFrame(n.loop)},this.update=function(t){n.y=t||window.pageYOffset},this.onIntersection=function(){return function(t,e){var i=n.options,o=i.shouldUnObserve,r=i.onEnter,a=i.onLeave;t.forEach(function(t){var i=t.target;t.isIntersecting?(o(i)&&e.unobserve(i),n.blobs.add(i),r(i),!n.within(i)&&n.markAsWithin(i)):(n.within(i)&&n.markAsNotWithin(i),a(i),n.blobs.delete(i))}),n.blobs.size>0&&null===n.handle&&n.loop(),0===n.blobs.length&&(cancelAnimationFrame(n.handle),n.handle=null)}}};return function o(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,o),i.call(this),this.nodes=[].concat(t(document.querySelectorAll(r))).map(function(t,n){return t.setAttribute("data-key",n),t}),this.options=e({},this.defaults,a);var s=this.options,u=s.rootMargin,h=s.threshold,l=new IntersectionObserver(this.onIntersection(),{rootMargin:u,threshold:h});this.nodes.forEach(function(t){return l.observe(t)}),this.blobs=new Set,this.handle=null,this.prevFrame=void 0}}); | ||
!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.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)&&node.setAttribute("data-inview","true")):(n.within(o)&&node.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 r(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"[data-inview]",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(this,r),o.call(this),this.options=t({},this.defaults,a);var s=this.options,l=s.rootMargin,u=s.threshold,f=new IntersectionObserver(this.onIntersection(),{rootMargin:l,threshold:u});this.nodes=[].concat(e(document.querySelectorAll(i))).map(function(e){return f.observe($node),e}),this.elements=new Set,this.handle=null}}); |
{ | ||
"name": "sponlax", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
4629
8