1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
|
"use strict";!function(e,t,r){var n,o,a={get:function(){return U},init:function(e){return U||new V(e)},VERSION:"0.6.30"},l=Object.prototype.hasOwnProperty,i=e.Math,s=e.getComputedStyle,c="touchstart",f="touchmove",u="touchcancel",d="touchend",m="skrollr",p="no-"+m,v=m+"-desktop",g=m+"-mobile",h=.004,y="skrollr-body",b=200,T=/^(?:input|textarea|button|select)$/i,k=/^\s+|\s+$/g,S=/^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/,w=/\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,x=/^(@?[a-z\-]+)\[(\w+)\]$/,_=/-([a-z0-9_])/g,E=function(e,t){return t.toUpperCase()},A=/[\-+]?[\d]*\.?[\d]+/g,F=/\{\?\}/g,C=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,H=/[a-z\-]+-gradient/g,D="",I="",P=function(){var e=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(s){var t=s(o,null);for(var r in t)if(D=r.match(e)||+r==r&&t[r].match(e))break;D?"-"===(D=D[0]).slice(0,1)?(I=D,D={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[D]):I="-"+D.toLowerCase()+"-":D=I=""}},N=function(){var t=e.requestAnimationFrame||e[D.toLowerCase()+"RequestAnimationFrame"],r=be();return!He&&t||(t=function(t){var n=be()-r,o=i.max(0,1e3/60-n);return e.setTimeout(function(){r=be(),t()},o)}),t},O={begin:function(){return 0},end:function(){return 1},linear:function(e){return e},quadratic:function(e){return e*e},cubic:function(e){return e*e*e},swing:function(e){return-i.cos(e*i.PI)/2+.5},sqrt:function(e){return i.sqrt(e)},outCubic:function(e){return i.pow(e-1,3)+1},bounce:function(e){var t;if(e<=.5083)t=3;else if(e<=.8489)t=9;else if(e<=.96208)t=27;else{if(!(e<=.99981))return 1;t=91}return 1-i.abs(3*i.cos(e*t*1.028)/t)}};function V(r){if(n=t.documentElement,o=t.body,P(),U=this,J=(r=r||{}).constants||{},r.easing)for(var a in r.easing)O[a]=r.easing[a];ae=r.edgeStrategy||"set",W={beforerender:r.beforerender,render:r.render,keyframe:r.keyframe},(Z=!1!==r.forceHeight)&&(Se=r.scale||1),Q=r.mobileDeceleration||h,te=!1!==r.smoothScrolling,re=r.smoothScrollingDuration||b,ne={targetTop:U.getScrollTop()},(He=(r.mobileCheck||function(){return/Android|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent||navigator.vendor||e.opera)})())?((j=t.getElementById(r.skrollrBody||y))&&R(),z(),ge(n,[m,g],[p])):ge(n,[m,v],[p]),U.refresh(),se(e,"resize orientationchange",function(){var e=n.clientWidth,t=n.clientHeight;t===Ae&&e===Ee||(Ae=t,Ee=e,Fe=!0)});var l=N();return function e(){q(),ie=l(e)}(),U}V.prototype.refresh=function(e){var r,n,o=!1;for(void 0===e?(o=!0,X=[],Ce=0,e=t.getElementsByTagName("*")):void 0===e.length&&(e=[e]),r=0,n=e.length;r<n;r++){var a=e[r],l=a,i=[],s=te,c=ae,f=!1;if(o&&"___skrollable_id"in a&&delete a.___skrollable_id,a.attributes){for(var u,d,m,p=0,v=a.attributes.length;p<v;p++){var g=a.attributes[p];if("data-anchor-target"!==g.name)if("data-smooth-scrolling"!==g.name)if("data-edge-strategy"!==g.name)if("data-emit-events"!==g.name){var h=g.name.match(S);if(null!==h){var y={props:g.value,element:a,eventType:g.name.replace(_,E)};i.push(y);var b=h[1];b&&(y.constant=b.substr(1));var T=h[2];/p$/.test(T)?(y.isPercentage=!0,y.offset=(0|T.slice(0,-1))/100):y.offset=0|T;var k=h[3],w=h[4]||k;k&&"start"!==k&&"end"!==k?(y.mode="relative",y.anchors=[k,w]):(y.mode="absolute","end"===k?y.isEnd=!0:y.isPercentage||(y.offset=y.offset*Se))}}else f=!0;else c=g.value;else s="off"!==g.value;else if(null===(l=t.querySelector(g.value)))throw'Unable to find anchor target "'+g.value+'"'}if(i.length)!o&&"___skrollable_id"in a?(m=a.___skrollable_id,u=X[m].styleAttr,d=X[m].classAttr):(m=a.___skrollable_id=Ce++,u=a.style.cssText,d=ve(a)),X[m]={element:a,styleAttr:u,classAttr:d,anchorTarget:l,keyFrames:i,smoothScrolling:s,edgeStrategy:c,emitEvents:f,lastFrameIndex:-1},ge(a,["skrollable"],[])}}for(de(),r=0,n=e.length;r<n;r++){var x=X[e[r].___skrollable_id];void 0!==x&&(L(x),$(x))}return U},V.prototype.relativeToAbsolute=function(e,t,r){var o=n.clientHeight,a=e.getBoundingClientRect(),l=a.top,i=a.bottom-a.top;return"bottom"===t?l-=o:"center"===t&&(l-=o/2),"bottom"===r?l+=i:"center"===r&&(l+=i/2),(l+=U.getScrollTop())+.5|0},V.prototype.animate
|