filesbox/web/dist/design/designstatic/home/js/scrollanim.min.js

2 lines
3.6 KiB
JavaScript
Raw Normal View History

2024-07-26 06:10:54 +00:00
/*! kissui.scrollanim 2016-08-07 */(function(l,s){typeof define=="function"&&define.amd?define([],function(){return l.kissuiPosition=s()}):l.kissuiPosition=s(l)})(this,function(){function l(t){if(t="Kissui.position: "+t,f.safeMode!=1)throw Error(t);console.log(t)}function s(){for(var t=document.querySelectorAll("*["+f.attribute+"]"),e=0;e<t.length;e++){var u=t[e],i=u.getAttribute(f.attribute);a(u,i)}}function a(t,e){for(var u=e.split(" "),i=!0,d=0;d<u.length;d++){var E=u[d];if(f.events.indexOf(E)==-1){i=!1;break}}i?o.push({element:t,event:e}):l("Invalid event name: `"+e+"`. Skipping "+t)}function O(){o=[]}function p(t,e){window.addEventListener?window.addEventListener(t,e,!1):window.attachEvent&&window.attachEvent("on"+t,e)}function y(t,e){var u=e.split(" "),i=!0,d=t.getBoundingClientRect().top,E=t.getBoundingClientRect().bottom,h=t.getBoundingClientRect().left,A=t.getBoundingClientRect().right,x=t.getBoundingClientRect().height,L=t.getBoundingClientRect().width,k=window.innerHeight||document.documentElement.clientHeight,w=document.body.clientWidth||document.documentElement.clientWidth;u.indexOf("in")>-1&&(i=d>=0&&h>=0&&E<=k&&A<=w&&i&&!0),u.indexOf("out")>-1&&(i=(d+x<0||h+L<0||h>w||d>k)&&i&&!0),u.indexOf("top")>-1&&(i=d==0&&i&&!0),u.indexOf("left")>-1&&(i=h==0&&i&&!0),u.indexOf("right")>-1&&(i=A==w&&i&&!0),u.indexOf("bottom")>-1&&(i=E==k&&i&&!0),u.indexOf("middle")>-1&&(i=d+x/2==k/2&&i&&!0),u.indexOf("center")>-1&&(i=h+L/2==w/2&&i&&!0),i&&(t.getAttribute("id")&&m(t.getAttribute("id"),t),m(e,t),m("*",t,e))}function v(t){for(var e=0;e<t.length;e++)y.call(this,t[e].element,t[e].event)}function g(t,e){typeof r[t]!="object"&&(r[t]=[]),r[t].push(e)}function m(t){var e,u,i,d=[].slice.call(arguments,1);if(typeof r[t]=="object")for(u=r[t].slice(),i=u.length,e=0;e<i;e++)u[e].apply(this,d)}function n(t,e){g(t,function u(){_removeListener(t,u),e.apply(this,arguments)})}function c(){s.call(this),f.triggerOnInit==1&&v.call(this,o),p("scroll",v.bind(this,o)),p("resize",v.bind(this,o))}var o=[],r=[],f={triggerOnInit:!0,attribute:"data-kui-position",safeMode:!1};return f.events=["in","out","middle","top","bottom","left","center","right"],_removeListener=function(t,e){var u;typeof r[t]=="object"&&(u=r[t].indexOf(e),u>-1&&r[t].splice(u,1))},{_options:f,_elements:o,on:g,once:n,removeListener:_removeListener,init:c,positions:v,add:a,reset:O}}),function(l,s){typeof define=="function"&&define.amd?define(["kissuiPosition"],function(a){return l.kissuiScrollAnim=s(a)}):l.kissuiScrollAnim=s(l.kissuiPosition)}(this,function(l){function s(){m=[];for(var n=document.querySelectorAll("*["+g.attribute+"]"),c=0;c<n.length;c++){var o=n[c],r=o.getAttribute(g.attribute);a(o,{in:r})}}function a(n,c){var o={};for(var r in c)l.add(n,r),o[r]={animation:c[r],active:!1};n.style.opacity="0",m.push({element:n,event:o})}function O(n){for(var c=0;c<m.length;c++){var o=m[c];if(n===o.element)return o}return null}function p(n,c){for(var o in n.event)o==c&&n.event[o].active===!1&&(n.element.style.opacity="1",n.element.className+=" animated "+n.event[o].animation,function(r,f){y(r.element,["webkitAnimationEnd","mozAnimationEnd","MSAnimationEnd","oanimationend","animationend"],function(){r.element.className=r.element.className.replace(" animated "+r.event[f].animation,""),r.event[f].active=!0})}(n,o))}function y(n,c,o){if(typeof c=="object")for(var r=0;r<c.length;r++)y(n,c[r],o);n.addEventListener?n.addEventListener(c,o,!1):n.attachEvent&&n.attachEvent("on"+c,o)}function v(){s.call(this),l.on("*",function(n,c){p(O(n),c)}),l.init()}var g={triggerOnInit:!0,attribute:"data-kui-anim"},m=[];return v(),{_options:g,_elements:m,init:v,add:a}});