UNPKG

1.31 kBJavaScriptView Raw
1var e,n,t,o,i,r,a,d,s,u=[];function c(e){return n=window.pageXOffset,o=window.pageYOffset,r=window.innerHeight,d=window.innerWidth,o===i&&n===t&&r===a&&d===s||(f(e),t=n,i=o,a=r,s=d),requestAnimationFrame(c)}function f(e){for(var c=0;c<u.length;c++)u[c]({x:n,y:o,px:t,py:i,vh:r,pvh:a,vw:d,pvw:s},e)}module.exports=function(n,t){void 0===n&&(n="data-animate"),void 0===t&&(t={});var o=new Map;return function(){o.forEach(function(e,n,t){!document.documentElement.contains(n)&&o.delete(n)});for(var i=document.querySelectorAll("["+n+"]"),r=function(n){var r,a;o.has(i[n])||o.set(i[n],(r=i[n],void 0===(a={threshold:t.threshold||0})&&(a={}),function(n,t){var o,i=!1,d=parseFloat(r.getAttribute("data-threshold")||a.threshold||0);return u.indexOf(o=function(){for(var e=[],o=arguments.length;o--;)e[o]=arguments[o];var a=e[0],s=a.y,u=a.vh,c=r.getBoundingClientRect(),f=c.top+s,l=d>=.5?d:d*u,h=f+c.height-l>=s&&f+l<=s+u;h&&!i?(i=!0,n&&n.apply(void 0,e)):!h&&i&&(i=!1,t&&t.apply(void 0,e))})<0&&u.push(o),e=e||c(performance.now()),f(performance.now()),function(){return u.splice(u.indexOf(o),1)}})(function(){i[n].classList.add("is-visible"),!t.reset&&o.delete(i[n])},function(){t.reset&&i[n].classList.remove("is-visible")}))},a=i.length-1;a>-1;a--)r(a);return function(){o.clear()}}};
2//# sourceMappingURL=rola.js.map