jahresbericht2017/assets/js/skrollr.js

1 line
12 KiB
JavaScript

!function(e,t,r){"use strict";function n(r){if(o=t.documentElement,a=t.body,_(),$=this,r=r||{},R=r.constants||{},r.easing)for(var n in r.easing)F[n]=r.easing[n];Q=r.edgeStrategy||"set",K={beforerender:r.beforerender,render:r.render,keyframe:r.keyframe},Y=r.forceHeight!==!1,Y&&(ge=r.scale||1),U=r.mobileDeceleration||p,j=r.smoothScrolling!==!1,W=r.smoothScrollingDuration||g,Z={targetTop:$.getScrollTop()},xe=(r.mobileCheck||function(){return/Android|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent||navigator.vendor||e.opera)})(),xe?(G=t.getElementById(r.skrollrBody||v),G&&M(),C(),fe(o,[f,m],[u])):fe(o,[f,d],[u]),$.refresh(),re(e,"resize orientationchange",function(){var e=o.clientWidth,t=o.clientHeight;t===ke&&e===Te||(ke=t,Te=e,Se=!0)});var l=E();return function e(){I(),te=l(e)}(),$}var o,a,l={get:function(){return $},init:function(e){return $||new n(e)},VERSION:"0.6.30"},i=Object.prototype.hasOwnProperty,s=e.Math,c=e.getComputedStyle,f="skrollr",u="no-"+f,d=f+"-desktop",m=f+"-mobile",p=.004,v="skrollr-body",g=200,h=/^(?:input|textarea|button|select)$/i,y=/\s*(@?[\w\-\[\]]+)\s*:\s*(.+?)\s*(?:;|$)/gi,b=function(e,t){return t.toUpperCase()},T=/\{\?\}/g,k=/rgba?\(\s*-?\d+\s*,\s*-?\d+\s*,\s*-?\d+/g,S=/[a-z\-]+-gradient/g,w="",x="",_=function(){var e=/^(?:O|Moz|webkit|ms)|(?:-(?:o|moz|webkit|ms)-)/;if(c){var t=c(a,null);for(var r in t)if(w=r.match(e)||+r==r&&t[r].match(e))break;if(!w)return void(w=x="");w=w[0],"-"===w.slice(0,1)?(x=w,w={"-webkit-":"webkit","-moz-":"Moz","-ms-":"ms","-o-":"O"}[w]):x="-"+w.toLowerCase()+"-"}},E=function(){var t=e.requestAnimationFrame||e[w.toLowerCase()+"RequestAnimationFrame"],r=me();return!xe&&t||(t=function(t){var n=me()-r,o=s.max(0,1e3/60-n);return e.setTimeout(function(){r=me(),t()},o)}),t},A=function(){var t=e.cancelAnimationFrame||e[w.toLowerCase()+"CancelAnimationFrame"];return!xe&&t||(t=function(t){return e.clearTimeout(t)}),t},F={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-s.cos(e*s.PI)/2+.5},sqrt:function(e){return s.sqrt(e)},outCubic:function(e){return s.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-s.abs(3*s.cos(e*t*1.028)/t)}};n.prototype.refresh=function(e){var r,n,o=!1;for(void 0===e?(o=!0,B=[],we=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=j,c=Q,f=!1;if(o&&"___skrollable_id"in a&&delete a.___skrollable_id,a.attributes){for(var u=0,d=a.attributes.length;u<d;u++){var m=a.attributes[u];if("data-anchor-target"!==m.name)if("data-smooth-scrolling"!==m.name)if("data-edge-strategy"!==m.name)if("data-emit-events"!==m.name){var p=m.name.match(/^data(?:-(_\w+))?(?:-?(-?\d*\.?\d+p?))?(?:-?(start|end|top|center|bottom))?(?:-?(top|center|bottom))?$/);if(null!==p){var v={props:m.value,element:a,eventType:m.name.replace(/-([a-z0-9_])/g,b)};i.push(v);var g=p[1];g&&(v.constant=g.substr(1));var h=p[2];/p$/.test(h)?(v.isPercentage=!0,v.offset=(0|h.slice(0,-1))/100):v.offset=0|h;var y=p[3],T=p[4]||y;y&&"start"!==y&&"end"!==y?(v.mode="relative",v.anchors=[y,T]):(v.mode="absolute","end"===y?v.isEnd=!0:v.isPercentage||(v.offset=v.offset*ge))}}else f=!0;else c=m.value;else s="off"!==m.value;else if(null===(l=t.querySelector(m.value)))throw'Unable to find anchor target "'+m.value+'"'}if(i.length){var k,S,w;!o&&"___skrollable_id"in a?(w=a.___skrollable_id,k=B[w].styleAttr,S=B[w].classAttr):(w=a.___skrollable_id=we++,k=a.style.cssText,S=ce(a)),B[w]={element:a,styleAttr:k,classAttr:S,anchorTarget:l,keyFrames:i,smoothScrolling:s,edgeStrategy:c,emitEvents:f,lastFrameIndex:-1},fe(a,["skrollable"],[])}}}for(le(),r=0,n=e.length;r<n;r++){var x=B[e[r].___skrollable_id];void 0!==x&&(P(x),N(x))}return $},n.prototype.relativeToAbsolute=function(e,t,r){var n=o.clientHeight,a=e.getBoundingClientRect(),l=a.top,i=a.bottom-a.top;return"bottom"===t?l-=n:"center"===t&&(l-=n/2),"bottom"===r?l+=i:"center"===r&&(l+=i/2),(l+=$.getScrollTop())+.5|0},n.prototype.animateTo=function(e,t){t=t||{};var r=me(),n=$.getScrollTop(),o=void 0===t.duration?1e3:t.duration;return X={startTop:n,topDiff:e-n,targetTop:e,duration:o,startTime:r,endTime:r+o,easing:F[t.easing||"linear"],done:t.done},X.topDiff||(X.done&&X.done.call($,!1),X=void 0),$},n.prototype.stopAnimateTo=function(){X&&X.done&&X.done.call($,!0),X=void 0},n.prototype.isAnimatingTo=function(){return!!X},n.prototype.isMobile=function(){return xe},n.prototype.setScrollTop=function(t,r){return J=r===!0,xe?_e=s.min(s.max(t,0),ve):e.scrollTo(0,t),$},n.prototype.getScrollTop=function(){return xe?_e:e.pageYOffset||o.scrollTop||a.scrollTop||0},n.prototype.getMaxScrollTop=function(){return ve},n.prototype.on=function(e,t){return K[e]=t,$},n.prototype.off=function(e){return delete K[e],$},n.prototype.destroy=function(){A()(te),oe(),fe(o,[u],[f,d,m]);for(var e=0,t=B.length;e<t;e++)L(B[e].element);o.style.overflow=a.style.overflow="",o.style.height=a.style.height="",G&&l.setStyle(G,"transform","none"),$=void 0,G=void 0,K=void 0,Y=void 0,ve=0,ge=1,R=void 0,U=void 0,he="down",ye=-1,Te=0,ke=0,Se=!1,X=void 0,j=void 0,W=void 0,Z=void 0,J=void 0,we=0,Q=void 0,xe=!1,_e=0,ee=void 0};var C=function(){var r,n,l,i,c,f,u,d,m,p,v,g;re(o,["touchstart","touchmove","touchcancel","touchend"].join(" "),function(e){var o=e.changedTouches[0];for(i=e.target;3===i.nodeType;)i=i.parentNode;switch(c=o.clientY,f=o.clientX,p=e.timeStamp,h.test(i.tagName)||e.preventDefault(),e.type){case"touchstart":r&&r.blur(),$.stopAnimateTo(),r=i,n=u=c,l=f,m=p;break;case"touchmove":h.test(i.tagName)&&t.activeElement!==i&&e.preventDefault(),d=c-u,g=p-v,$.setScrollTop(_e-d,!0),u=c,v=p;break;default:case"touchcancel":case"touchend":var a=n-c,y=l-f;if(y*y+a*a<49){if(!h.test(r.tagName)){r.focus();var b=t.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,e.view,1,o.screenX,o.screenY,o.clientX,o.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null),r.dispatchEvent(b)}return}r=void 0;var T=d/g;T=s.max(s.min(T,3),-3);var k=s.abs(T/U),S=T*k+.5*U*k*k,w=$.getScrollTop()-S,x=0;w>ve?(x=(ve-w)/S,w=ve):w<0&&(x=-w/S,w=0),k*=1-x,$.animateTo(w+.5|0,{easing:"outCubic",duration:k})}}),e.scrollTo(0,0),o.style.overflow=a.style.overflow="hidden"},H=function(){var e,t,r,n,a,l,i,c,f,u,d,m=o.clientHeight,p=ie();for(c=0,f=B.length;c<f;c++)for(e=B[c],t=e.element,r=e.anchorTarget,n=e.keyFrames,a=0,l=n.length;a<l;a++)i=n[a],u=i.offset,d=p[i.constant]||0,i.frame=u,i.isPercentage&&(u*=m,i.frame=u),"relative"===i.mode&&(L(t),i.frame=$.relativeToAbsolute(r,i.anchors[0],i.anchors[1])-u,L(t,!0)),i.frame+=d,Y&&!i.isEnd&&i.frame>ve&&(ve=i.frame);for(ve=s.max(ve,se()),c=0,f=B.length;c<f;c++){for(e=B[c],n=e.keyFrames,a=0,l=n.length;a<l;a++)i=n[a],d=p[i.constant]||0,i.isEnd&&(i.frame=ve-i.offset+d);e.keyFrames.sort(pe)}},D=function(e,t){for(var r=0,n=B.length;r<n;r++){var o,a,s=B[r],c=s.element,f=s.smoothScrolling?e:t,u=s.keyFrames,d=u.length,m=u[0],p=u[u.length-1],v=f<m.frame,g=f>p.frame,h=v?m:p,y=s.emitEvents,b=s.lastFrameIndex;if(v||g){if(v&&s.edge===-1||g&&1===s.edge)continue;switch(v?(fe(c,["skrollable-before"],["skrollable-after","skrollable-between"]),y&&b>-1&&(ae(c,m.eventType,he),s.lastFrameIndex=-1)):(fe(c,["skrollable-after"],["skrollable-before","skrollable-between"]),y&&b<d&&(ae(c,p.eventType,he),s.lastFrameIndex=d)),s.edge=v?-1:1,s.edgeStrategy){case"reset":L(c);continue;case"ease":f=h.frame;break;default:case"set":var T=h.props;for(o in T)i.call(T,o)&&(a=q(T[o].value),0===o.indexOf("@")?c.setAttribute(o.substr(1),a):l.setStyle(c,o,a));continue}}else 0!==s.edge&&(fe(c,["skrollable","skrollable-between"],["skrollable-before","skrollable-after"]),s.edge=0);for(var k=0;k<d-1;k++)if(f>=u[k].frame&&f<=u[k+1].frame){var S=u[k],w=u[k+1];for(o in S.props)if(i.call(S.props,o)){var x=(f-S.frame)/(w.frame-S.frame);x=S.props[o].easing(x),a=V(S.props[o].value,w.props[o].value,x),a=q(a),0===o.indexOf("@")?c.setAttribute(o.substr(1),a):l.setStyle(c,o,a)}y&&b!==k&&("down"===he?ae(c,S.eventType,he):ae(c,w.eventType,he),s.lastFrameIndex=k);break}}},I=function(){Se&&(Se=!1,le());var e,t,r=$.getScrollTop(),n=me();if(X)n>=X.endTime?(r=X.targetTop,e=X.done,X=void 0):(t=X.easing((n-X.startTime)/X.duration),r=X.startTop+t*X.topDiff|0),$.setScrollTop(r,!0);else if(!J){var o=Z.targetTop-r;o&&(Z={startTop:ye,topDiff:r-ye,targetTop:r,startTime:be,endTime:be+W}),n<=Z.endTime&&(t=F.sqrt((n-Z.startTime)/W),r=Z.startTop+t*Z.topDiff|0)}if(J||ye!==r){he=r>ye?"down":r<ye?"up":he,J=!1;var a={curTop:r,lastTop:ye,maxTop:ve,direction:he};(K.beforerender&&K.beforerender.call($,a))!==!1&&(D(r,$.getScrollTop()),xe&&G&&l.setStyle(G,"transform","translate(0, "+-_e+"px) "+ee),ye=r,K.render&&K.render.call($,a)),e&&e.call($,!1)}be=n},P=function(e){for(var t=0,r=e.keyFrames.length;t<r;t++){for(var n,o,a,l,i=e.keyFrames[t],s={};null!==(l=y.exec(i.props));)a=l[1],o=l[2],n=a.match(/^(@?[a-z\-]+)\[(\w+)\]$/),null!==n?(a=n[1],n=n[2]):n="linear",o=o.indexOf("!")?z(o):[o.slice(1)],s[a]={value:o,easing:F[n]};i.props=s}},z=function(e){var t=[];return k.lastIndex=0,e=e.replace(k,function(e){return e.replace(/[\-+]?[\d]*\.?[\d]+/g,function(e){return e/255*100+"%"})}),x&&(S.lastIndex=0,e=e.replace(S,function(e){return x+e})),e=e.replace(/[\-+]?[\d]*\.?[\d]+/g,function(e){return t.push(+e),"{?}"}),t.unshift(e),t},N=function(e){var t,r,n={};for(t=0,r=e.keyFrames.length;t<r;t++)O(e.keyFrames[t],n);for(n={},t=e.keyFrames.length-1;t>=0;t--)O(e.keyFrames[t],n)},O=function(e,t){var r;for(r in t)i.call(e.props,r)||(e.props[r]=t[r]);for(r in e.props)t[r]=e.props[r]},V=function(e,t,r){var n,o=e.length;if(o!==t.length)throw"Can't interpolate between \""+e[0]+'" and "'+t[0]+'"';var a=[e[0]];for(n=1;n<o;n++)a[n]=e[n]+(t[n]-e[n])*r;return a},q=function(e){var t=1;return T.lastIndex=0,e[0].replace(T,function(){return e[t++]})},L=function(e,t){e=[].concat(e);for(var r,n,o=0,a=e.length;o<a;o++)n=e[o],(r=B[n.___skrollable_id])&&(t?(n.style.cssText=r.dirtyStyleAttr,fe(n,r.dirtyClassAttr)):(r.dirtyStyleAttr=n.style.cssText,r.dirtyClassAttr=ce(n),n.style.cssText=r.styleAttr,fe(n,r.classAttr)))},M=function(){ee="translateZ(0)",l.setStyle(G,"transform",ee);var e=c(G),t=e.getPropertyValue("transform"),r=e.getPropertyValue(x+"transform");t&&"none"!==t||r&&"none"!==r||(ee="")};l.setStyle=function(e,t,r){var n=e.style;if("zIndex"===(t=t.replace(/-([a-z0-9_])/g,b).replace("-","")))isNaN(r)?n[t]=r:n[t]=""+(0|r);else if("float"===t)n.styleFloat=n.cssFloat=r;else try{w&&(n[w+t.slice(0,1).toUpperCase()+t.slice(1)]=r),n[t]=r}catch(e){}};var $,B,G,K,Y,R,U,X,j,W,Z,J,Q,ee,te,re=l.addEvent=function(t,r,n){var o=function(t){return t=t||e.event,t.target||(t.target=t.srcElement),t.preventDefault||(t.preventDefault=function(){t.returnValue=!1,t.defaultPrevented=!0}),n.call(this,t)};r=r.split(" ");for(var a,l=0,i=r.length;l<i;l++)a=r[l],t.addEventListener?t.addEventListener(a,n,!1):t.attachEvent("on"+a,o),Ee.push({element:t,name:a,listener:n})},ne=l.removeEvent=function(e,t,r){t=t.split(" ");for(var n=0,o=t.length;n<o;n++)e.removeEventListener?e.removeEventListener(t[n],r,!1):e.detachEvent("on"+t[n],r)},oe=function(){for(var e,t=0,r=Ee.length;t<r;t++)e=Ee[t],ne(e.element,e.name,e.listener);Ee=[]},ae=function(e,t,r){K.keyframe&&K.keyframe.call($,e,t,r)},le=function(){var e=$.getScrollTop();ve=0,Y&&!xe&&(a.style.height=""),H(),Y&&!xe&&(a.style.height=ve+o.clientHeight+"px"),xe?$.setScrollTop(s.min($.getScrollTop(),ve)):$.setScrollTop(e,!0),J=!0},ie=function(){var e,t,r=o.clientHeight,n={};for(e in R)t=R[e],"function"==typeof t?t=t.call($):/p$/.test(t)&&(t=t.slice(0,-1)/100*r),n[e]=t;return n},se=function(){var e=0;return G&&(e=s.max(G.offsetHeight,G.scrollHeight)),s.max(e,a.scrollHeight,a.offsetHeight,o.scrollHeight,o.offsetHeight,o.clientHeight)-o.clientHeight},ce=function(t){var r="className";return e.SVGElement&&t instanceof e.SVGElement&&(t=t[r],r="baseVal"),t[r]},fe=function(t,r,n){var o="className";if(e.SVGElement&&t instanceof e.SVGElement&&(t=t[o],o="baseVal"),void 0===n)return void(t[o]=r);for(var a=t[o],l=0,i=n.length;l<i;l++)a=de(a).replace(de(n[l])," ");a=ue(a);for(var s=0,c=r.length;s<c;s++)de(a).indexOf(de(r[s]))===-1&&(a+=" "+r[s]);t[o]=ue(a)},ue=function(e){return e.replace(/^\s+|\s+$/g,"")},de=function(e){return" "+e+" "},me=Date.now||function(){return+new Date},pe=function(e,t){return e.frame-t.frame},ve=0,ge=1,he="down",ye=-1,be=me(),Te=0,ke=0,Se=!1,we=0,xe=!1,_e=0,Ee=[];"function"==typeof define&&define.amd?define([],function(){return l}):"undefined"!=typeof module&&module.exports?module.exports=l:e.skrollr=l}(window,document);