@apatheticwes/scrollify
Advanced tools
Comparing version 1.0.2-alpha to 1.0.3-alpha
/*! | ||
* Scrollify 1.0.1-alpha | ||
* Scrollify 1.0.3-alpha | ||
* | ||
@@ -8,2 +8,2 @@ * @link https://github.com/apathetic/scrollify | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){return"function"==typeof t},n=function(t){return t instanceof HTMLElement?t:document.querySelector(t)},e=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},r=function(t,n,e){return(n-t)*e+t},o=function(t){var n=t.transforms,e=t.options;return function(t){n.position[1]=r.apply(void 0,e.concat([t]))}},a=o,i=function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[2]=r.apply(void 0,e.concat([t]))}},s=i,u=function(t){var n=t.element,e=t.options;return function(t){n.style.opacity=r.apply(void 0,e.concat([t]))}},c=function(t){var n=t.element,e=t.options;return function(t){n.style.filter="blur("+r.apply(void 0,e.concat([t]))+"px)"}},f=function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var o=e[r];n.classList.toggle(o,t>+r)}))}},l=function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}};[l,f,c,u].forEach((function(t){Object.defineProperty(t,"skipMatrix",{value:!0})}));var p=Object.freeze({__proto__:null,translateX:function(t){var n=t.transforms,e=t.options;return function(t){n.position[0]=r.apply(void 0,e.concat([t]))}},translateY:o,parallax:a,rotateX:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[0]=r.apply(void 0,e.concat([t]))}},rotateY:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[1]=r.apply(void 0,e.concat([t]))}},rotateZ:i,rotate:s,scaleX:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=r.apply(void 0,e.concat([t]))}},scaleY:function(t){var n=t.transforms,e=t.options;return void 0===e&&(e=[n.scale[1],1]),function(t){n.scale[1]=r.apply(void 0,e.concat([t]))}},scale:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=n.scale[1]=r.apply(void 0,e.concat([t]))}},skewX:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=r.apply(void 0,e.concat([t]))}},skewY:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[1]=r.apply(void 0,e.concat([t]))}},skew:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=n.skew[1]=r.apply(void 0,e.concat([t]))}},fade:u,blur:c,toggle:f,stick:l});var h=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)+n},easeOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/a)+e+n},easeInOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(a||(a=r*(.3*1.5)),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*.5+e+n},easeInBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*(t/=r)*t*((o+1)*t-o)+n},easeOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*((t=t/r-1)*t*((o+1)*t+o)+1)+n},easeInOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(o*=1.525))*t-o))+n:e/2*((t-=2)*t*((1+(o*=1.525))*t+o)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function d(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function v(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function M(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function m(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return v(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){v(t)},translate:function(r,o,a){return M(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,o,a),d(n,e,t),this},rotateX:function(r){var o,a;return M(t,n),a=r,(o=e)[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=Math.cos(a),o[6]=-Math.sin(a),o[7]=0,o[8]=0,o[9]=Math.sin(a),o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,d(n,e,t),this},rotateY:function(r){var o,a;return M(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=0,o[2]=Math.sin(a),o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=-Math.sin(a),o[9]=0,o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,d(n,e,t),this},rotateZ:function(r){var o,a;return M(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=-Math.sin(a),o[2]=0,o[3]=0,o[4]=Math.sin(a),o[5]=Math.cos(a),o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,d(n,e,t),this},scale:function(r,o){return M(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),d(n,e,t),this},skew:function(r,o){return M(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),d(n,e,t),this}}}var w=1,y=2,g=3;function O(t,n,e){if(void 0===n&&(n=[]),"number"==typeof t)return t;var r=window.innerWidth,o=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*r})).replace(/(\d*)vh/g,(function(t,n){return.01*n*o})).replace(/px/g,"")+");")(n,e,(function(t,n){return parseFloat(window.getComputedStyle(n)[t])||0}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)}))}var I=function t(e){var r=this;(e=n(e))?(e.dataset.scrollify,this.scenes=[],this.element=e,this.ticking=!1,this.active=!0,this.matrix=m(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return r.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return r.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};I.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},I.prototype.addScene=function(r){var o=this,a=this.element,i=this.transforms,s=r.start;void 0===s&&(s="0, el.top - 100vh");var u=r.end;void 0===u&&(u="el.bottom");var c=r.easing,f=r.refs;void 0===f&&(f=[]);var l=r.effects;void 0===l&&(l={});var d=function(n,e){return Object.keys(l).reduce((function(r,o){var s,u,c,f=l[o];return t(f)?s=f:(s=p[o],c=f,u=Array.isArray(c)?f.map((function(t){return O(t,n,e)})):f),r.push(s({element:a,transforms:i,options:u})),r}),[])},v={start:0,duration:0,state:"",easing:t(c)?c:h[c],effects:[],reset:function(){var t=window.scrollY,r=e(a),i=function(t){return t.map(n).map(e)}(f),c=O(s,i,r),l=O(u,i,r),p=d(i,r);v.effects=p,v.start=c,v.duration=l-c,v.state=t>c?t>l?y:g:w,o.update(v)}};return r.skipMatrix?v.skipMatrix=!0:a.style.willChange="transform",v.reset(),r.debug&&console.log("Scrollify scene: ",v),this.scenes.push(v),this},I.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},I.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},I.prototype.update=function(t){var n,e=t.start,r=t.duration,o=t.easing,a=t.effects,i=window.scrollY;if(i-e>r){if(t.state===y)return;t.state=y,n=1}else if(i-e<0){if(t.state===w)return;t.state=w,n=0}else t.state=g,n=o?o(i-e,0,1,r):(i-e)/r;a.forEach((function(t){return t(n)})),t.skipMatrix||(this.element.style.transform=this.updateMatrix().asCSS())},I.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},I.prototype.disable=function(){this.active=!1},exports.Scrollify=I,exports.default=I,exports.easings=h,exports.fx=p; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t,n,e){return(n-t)*e+t},n=function(t,n){return window.getComputedStyle(n)[t]||0},e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)},r=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)},o=function(t){return"function"==typeof t},a=function(t){return 1===t.nodeType?t:document.querySelector(t)},i=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},s=function(n){var e=n.transforms,r=n.options;return function(n){e.position[0]=t.apply(void 0,r.concat([n]))}},u=function(n){var e=n.transforms,r=n.options;return function(n){e.position[1]=t.apply(void 0,r.concat([n]))}},c=u,f=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[0]=t.apply(void 0,r.concat([n]))}},l=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[1]=t.apply(void 0,r.concat([n]))}},p=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[2]=t.apply(void 0,r.concat([n]))}},h=p,d=function(n){var e=n.transforms,r=n.options;return function(n){e.scale[0]=t.apply(void 0,r.concat([n]))}},v=function(n){var e=n.transforms,r=n.options;return void 0===r&&(r=[e.scale[1],1]),function(n){e.scale[1]=t.apply(void 0,r.concat([n]))}},M=function(n){var e=n.transforms,r=n.options;return function(n){e.scale[0]=e.scale[1]=t.apply(void 0,r.concat([n]))}},w=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[0]=t.apply(void 0,r.concat([n]))}},m=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[1]=t.apply(void 0,r.concat([n]))}},y=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[0]=e.skew[1]=t.apply(void 0,r.concat([n]))}};[s,u,f,l,p,M,d,v,y,w,m].forEach((function(t){Object.defineProperty(t,"useMatrix",{value:!0})}));var g=Object.freeze({__proto__:null,translateX:s,translateY:u,parallax:c,rotateX:f,rotateY:l,rotateZ:p,rotate:h,scaleX:d,scaleY:v,scale:M,skewX:w,skewY:m,skew:y,fade:function(n){var e=n.element,r=n.options;return function(n){e.style.opacity=t.apply(void 0,r.concat([n]))}},blur:function(n){var e=n.element,r=n.options;return function(n){e.style.filter="blur("+t.apply(void 0,r.concat([n]))+"px)"}},toggle:function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var o=e[r];n.classList.toggle(o,t>+r)}))}},stick:function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}}});var O=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)+n},easeOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/a)+e+n},easeInOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(a||(a=r*(.3*1.5)),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*.5+e+n},easeInBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*(t/=r)*t*((o+1)*t-o)+n},easeOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*((t=t/r-1)*t*((o+1)*t+o)+1)+n},easeInOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(o*=1.525))*t-o))+n:e/2*((t-=2)*t*((1+(o*=1.525))*t+o)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function I(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function x(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function b(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function k(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return x(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){x(t)},translate:function(r,o,a){return b(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,o,a),I(n,e,t),this},rotateX:function(r){var o,a;return b(t,n),a=r,(o=e)[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=Math.cos(a),o[6]=-Math.sin(a),o[7]=0,o[8]=0,o[9]=Math.sin(a),o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,I(n,e,t),this},rotateY:function(r){var o,a;return b(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=0,o[2]=Math.sin(a),o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=-Math.sin(a),o[9]=0,o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,I(n,e,t),this},rotateZ:function(r){var o,a;return b(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=-Math.sin(a),o[2]=0,o[3]=0,o[4]=Math.sin(a),o[5]=Math.cos(a),o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,I(n,e,t),this},scale:function(r,o){return b(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),I(n,e,t),this},skew:function(r,o){return b(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),I(n,e,t),this}}}var S=1,E=2,_=3;function P(t,o,a){if(void 0===o&&(o=[]),"number"==typeof t)return t;var i=window.innerWidth,s=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*i})).replace(/(\d*)vh/g,(function(t,n){return.01*n*s})).replace(/px/g,"")+");")(o,a,n,e,r)}var C=function t(n){var e=this;(n=a(n))?(n.dataset.scrollify,this.scenes=[],this.element=n,this.ticking=!1,this.active=!0,this.matrix=k(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return e.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return e.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};C.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},C.prototype.addScene=function(t){var n=this,e=this.element,r=this.transforms,s=t.start;void 0===s&&(s="0, el.top - 100vh");var u=t.end;void 0===u&&(u="el.bottom");var c=t.easing,f=t.refs;void 0===f&&(f=[]);var l=t.effects;void 0===l&&(l={});var p=!1,h=function(t,n){return Object.keys(l).reduce((function(a,i){var s,u,c,f=l[i];return o(f)?s=f:(s=g[i],c=f,u=Array.isArray(c)?f.map((function(e){return P(e,t,n)})):f),p=p||s.useMatrix,a.push(s({element:e,transforms:r,options:u})),a}),[])},d={start:0,duration:0,state:"",easing:o(c)?c:O[c],effects:[],reset:function(){var t=window.scrollY,r=i(e),o=function(t){return t.map(a).map(i)}(f),c=P(s,o,r),l=P(u,o,r),v=h(o,r);d.effects=v,d.start=c,d.duration=l-c,d.state=t>c?t>l?E:_:S,d.useMatrix=p,n.update(d)}};return d.reset(),p&&(e.style.willChange="transform"),t.debug&&console.log("Scrollify scene: ",d),this.scenes.push(d),this},C.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},C.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},C.prototype.update=function(t){var n,e=t.start,r=t.duration,o=t.easing,a=t.effects,i=window.scrollY;if(i-e>r){if(t.state===E)return;t.state=E,n=1}else if(i-e<0){if(t.state===S)return;t.state=S,n=0}else t.state=_,n=o?o(i-e,0,1,r):(i-e)/r;a.forEach((function(t){return t(n)})),t.useMatrix&&(this.element.style.transform=this.updateMatrix().asCSS())},C.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},C.prototype.disable=function(){this.active=!1},exports.Scrollify=C,exports.default=C,exports.easings=O,exports.fx=g; |
/*! | ||
* Scrollify 1.0.1-alpha | ||
* Scrollify 1.0.3-alpha | ||
* | ||
@@ -8,2 +8,2 @@ * @link https://github.com/apathetic/scrollify | ||
*/ | ||
var t=function(t){return"function"==typeof t},n=function(t){return t instanceof HTMLElement?t:document.querySelector(t)},e=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},r=function(t,n,e){return(n-t)*e+t},a=function(t){var n=t.transforms,e=t.options;return function(t){n.position[1]=r.apply(void 0,e.concat([t]))}},o=a,i=function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[2]=r.apply(void 0,e.concat([t]))}},s=i,u=function(t){var n=t.element,e=t.options;return function(t){n.style.opacity=r.apply(void 0,e.concat([t]))}},c=function(t){var n=t.element,e=t.options;return function(t){n.style.filter="blur("+r.apply(void 0,e.concat([t]))+"px)"}},f=function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var a=e[r];n.classList.toggle(a,t>+r)}))}},l=function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}};[l,f,c,u].forEach((function(t){Object.defineProperty(t,"skipMatrix",{value:!0})}));var p=Object.freeze({__proto__:null,translateX:function(t){var n=t.transforms,e=t.options;return function(t){n.position[0]=r.apply(void 0,e.concat([t]))}},translateY:a,parallax:o,rotateX:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[0]=r.apply(void 0,e.concat([t]))}},rotateY:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[1]=r.apply(void 0,e.concat([t]))}},rotateZ:i,rotate:s,scaleX:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=r.apply(void 0,e.concat([t]))}},scaleY:function(t){var n=t.transforms,e=t.options;return void 0===e&&(e=[n.scale[1],1]),function(t){n.scale[1]=r.apply(void 0,e.concat([t]))}},scale:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=n.scale[1]=r.apply(void 0,e.concat([t]))}},skewX:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=r.apply(void 0,e.concat([t]))}},skewY:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[1]=r.apply(void 0,e.concat([t]))}},skew:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=n.skew[1]=r.apply(void 0,e.concat([t]))}},fade:u,blur:c,toggle:f,stick:l});var h=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+n},easeOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+e+n},easeInOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(o||(o=r*(.3*1.5)),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+e+n},easeInBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*(t/=r)*t*((a+1)*t-a)+n},easeOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*((t=t/r-1)*t*((a+1)*t+a)+1)+n},easeInOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(a*=1.525))*t-a))+n:e/2*((t-=2)*t*((1+(a*=1.525))*t+a)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function v(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function d(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function M(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function m(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return d(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){d(t)},translate:function(r,a,o){return M(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,a,o),v(n,e,t),this},rotateX:function(r){var a,o;return M(t,n),o=r,(a=e)[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=Math.cos(o),a[6]=-Math.sin(o),a[7]=0,a[8]=0,a[9]=Math.sin(o),a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,v(n,e,t),this},rotateY:function(r){var a,o;return M(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=0,a[2]=Math.sin(o),a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=-Math.sin(o),a[9]=0,a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,v(n,e,t),this},rotateZ:function(r){var a,o;return M(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=-Math.sin(o),a[2]=0,a[3]=0,a[4]=Math.sin(o),a[5]=Math.cos(o),a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,v(n,e,t),this},scale:function(r,a){return M(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),v(n,e,t),this},skew:function(r,a){return M(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),v(n,e,t),this}}}var w=1,y=2,g=3;function O(t,n,e){if(void 0===n&&(n=[]),"number"==typeof t)return t;var r=window.innerWidth,a=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*r})).replace(/(\d*)vh/g,(function(t,n){return.01*n*a})).replace(/px/g,"")+");")(n,e,(function(t,n){return parseFloat(window.getComputedStyle(n)[t])||0}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)}))}var I=function t(e){var r=this;(e=n(e))?(e.dataset.scrollify,this.scenes=[],this.element=e,this.ticking=!1,this.active=!0,this.matrix=m(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return r.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return r.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};I.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},I.prototype.addScene=function(r){var a=this,o=this.element,i=this.transforms,s=r.start;void 0===s&&(s="0, el.top - 100vh");var u=r.end;void 0===u&&(u="el.bottom");var c=r.easing,f=r.refs;void 0===f&&(f=[]);var l=r.effects;void 0===l&&(l={});var v=function(n,e){return Object.keys(l).reduce((function(r,a){var s,u,c,f=l[a];return t(f)?s=f:(s=p[a],c=f,u=Array.isArray(c)?f.map((function(t){return O(t,n,e)})):f),r.push(s({element:o,transforms:i,options:u})),r}),[])},d={start:0,duration:0,state:"",easing:t(c)?c:h[c],effects:[],reset:function(){var t=window.scrollY,r=e(o),i=function(t){return t.map(n).map(e)}(f),c=O(s,i,r),l=O(u,i,r),p=v(i,r);d.effects=p,d.start=c,d.duration=l-c,d.state=t>c?t>l?y:g:w,a.update(d)}};return r.skipMatrix?d.skipMatrix=!0:o.style.willChange="transform",d.reset(),r.debug&&console.log("Scrollify scene: ",d),this.scenes.push(d),this},I.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},I.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},I.prototype.update=function(t){var n,e=t.start,r=t.duration,a=t.easing,o=t.effects,i=window.scrollY;if(i-e>r){if(t.state===y)return;t.state=y,n=1}else if(i-e<0){if(t.state===w)return;t.state=w,n=0}else t.state=g,n=a?a(i-e,0,1,r):(i-e)/r;o.forEach((function(t){return t(n)})),t.skipMatrix||(this.element.style.transform=this.updateMatrix().asCSS())},I.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},I.prototype.disable=function(){this.active=!1};export default I;export{I as Scrollify,h as easings,p as fx}; | ||
var t=function(t,n,e){return(n-t)*e+t},n=function(t,n){return window.getComputedStyle(n)[t]||0},e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)},r=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)},a=function(t){return"function"==typeof t},o=function(t){return 1===t.nodeType?t:document.querySelector(t)},i=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},s=function(n){var e=n.transforms,r=n.options;return function(n){e.position[0]=t.apply(void 0,r.concat([n]))}},u=function(n){var e=n.transforms,r=n.options;return function(n){e.position[1]=t.apply(void 0,r.concat([n]))}},c=u,f=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[0]=t.apply(void 0,r.concat([n]))}},l=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[1]=t.apply(void 0,r.concat([n]))}},p=function(n){var e=n.transforms,r=n.options;return function(n){e.rotation[2]=t.apply(void 0,r.concat([n]))}},h=p,d=function(n){var e=n.transforms,r=n.options;return function(n){e.scale[0]=t.apply(void 0,r.concat([n]))}},v=function(n){var e=n.transforms,r=n.options;return void 0===r&&(r=[e.scale[1],1]),function(n){e.scale[1]=t.apply(void 0,r.concat([n]))}},M=function(n){var e=n.transforms,r=n.options;return function(n){e.scale[0]=e.scale[1]=t.apply(void 0,r.concat([n]))}},w=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[0]=t.apply(void 0,r.concat([n]))}},m=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[1]=t.apply(void 0,r.concat([n]))}},y=function(n){var e=n.transforms,r=n.options;return function(n){e.skew[0]=e.skew[1]=t.apply(void 0,r.concat([n]))}};[s,u,f,l,p,M,d,v,y,w,m].forEach((function(t){Object.defineProperty(t,"useMatrix",{value:!0})}));var g=Object.freeze({__proto__:null,translateX:s,translateY:u,parallax:c,rotateX:f,rotateY:l,rotateZ:p,rotate:h,scaleX:d,scaleY:v,scale:M,skewX:w,skewY:m,skew:y,fade:function(n){var e=n.element,r=n.options;return function(n){e.style.opacity=t.apply(void 0,r.concat([n]))}},blur:function(n){var e=n.element,r=n.options;return function(n){e.style.filter="blur("+t.apply(void 0,r.concat([n]))+"px)"}},toggle:function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var a=e[r];n.classList.toggle(a,t>+r)}))}},stick:function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}}});var O=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+n},easeOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+e+n},easeInOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(o||(o=r*(.3*1.5)),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+e+n},easeInBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*(t/=r)*t*((a+1)*t-a)+n},easeOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*((t=t/r-1)*t*((a+1)*t+a)+1)+n},easeInOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(a*=1.525))*t-a))+n:e/2*((t-=2)*t*((1+(a*=1.525))*t+a)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function I(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function x(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function b(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function k(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return x(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){x(t)},translate:function(r,a,o){return b(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,a,o),I(n,e,t),this},rotateX:function(r){var a,o;return b(t,n),o=r,(a=e)[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=Math.cos(o),a[6]=-Math.sin(o),a[7]=0,a[8]=0,a[9]=Math.sin(o),a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,I(n,e,t),this},rotateY:function(r){var a,o;return b(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=0,a[2]=Math.sin(o),a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=-Math.sin(o),a[9]=0,a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,I(n,e,t),this},rotateZ:function(r){var a,o;return b(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=-Math.sin(o),a[2]=0,a[3]=0,a[4]=Math.sin(o),a[5]=Math.cos(o),a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,I(n,e,t),this},scale:function(r,a){return b(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),I(n,e,t),this},skew:function(r,a){return b(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),I(n,e,t),this}}}var S=1,E=2,C=3;function P(t,a,o){if(void 0===a&&(a=[]),"number"==typeof t)return t;var i=window.innerWidth,s=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*i})).replace(/(\d*)vh/g,(function(t,n){return.01*n*s})).replace(/px/g,"")+");")(a,o,n,e,r)}var _=function t(n){var e=this;(n=o(n))?(n.dataset.scrollify,this.scenes=[],this.element=n,this.ticking=!1,this.active=!0,this.matrix=k(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return e.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return e.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};_.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},_.prototype.addScene=function(t){var n=this,e=this.element,r=this.transforms,s=t.start;void 0===s&&(s="0, el.top - 100vh");var u=t.end;void 0===u&&(u="el.bottom");var c=t.easing,f=t.refs;void 0===f&&(f=[]);var l=t.effects;void 0===l&&(l={});var p=!1,h=function(t,n){return Object.keys(l).reduce((function(o,i){var s,u,c,f=l[i];return a(f)?s=f:(s=g[i],c=f,u=Array.isArray(c)?f.map((function(e){return P(e,t,n)})):f),p=p||s.useMatrix,o.push(s({element:e,transforms:r,options:u})),o}),[])},d={start:0,duration:0,state:"",easing:a(c)?c:O[c],effects:[],reset:function(){var t=window.scrollY,r=i(e),a=function(t){return t.map(o).map(i)}(f),c=P(s,a,r),l=P(u,a,r),v=h(a,r);d.effects=v,d.start=c,d.duration=l-c,d.state=t>c?t>l?E:C:S,d.useMatrix=p,n.update(d)}};return d.reset(),p&&(e.style.willChange="transform"),t.debug&&console.log("Scrollify scene: ",d),this.scenes.push(d),this},_.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},_.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},_.prototype.update=function(t){var n,e=t.start,r=t.duration,a=t.easing,o=t.effects,i=window.scrollY;if(i-e>r){if(t.state===E)return;t.state=E,n=1}else if(i-e<0){if(t.state===S)return;t.state=S,n=0}else t.state=C,n=a?a(i-e,0,1,r):(i-e)/r;o.forEach((function(t){return t(n)})),t.useMatrix&&(this.element.style.transform=this.updateMatrix().asCSS())},_.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},_.prototype.disable=function(){this.active=!1};export default _;export{_ as Scrollify,O as easings,g as fx}; |
/*! | ||
* Scrollify 1.0.1-alpha | ||
* Scrollify 1.0.3-alpha | ||
* | ||
@@ -8,2 +8,2 @@ * @link https://github.com/apathetic/scrollify | ||
*/ | ||
var Scrollify=function(t){"use strict";var n=function(t){return"function"==typeof t},e=function(t){return t instanceof HTMLElement?t:document.querySelector(t)},r=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},a=function(t,n,e){return(n-t)*e+t},o=function(t){var n=t.transforms,e=t.options;return function(t){n.position[1]=a.apply(void 0,e.concat([t]))}},i=o,s=function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[2]=a.apply(void 0,e.concat([t]))}},u=s,c=function(t){var n=t.element,e=t.options;return function(t){n.style.opacity=a.apply(void 0,e.concat([t]))}},f=function(t){var n=t.element,e=t.options;return function(t){n.style.filter="blur("+a.apply(void 0,e.concat([t]))+"px)"}},l=function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var a=e[r];n.classList.toggle(a,t>+r)}))}},p=function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}};[p,l,f,c].forEach((function(t){Object.defineProperty(t,"skipMatrix",{value:!0})}));var h=Object.freeze({__proto__:null,translateX:function(t){var n=t.transforms,e=t.options;return function(t){n.position[0]=a.apply(void 0,e.concat([t]))}},translateY:o,parallax:i,rotateX:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[0]=a.apply(void 0,e.concat([t]))}},rotateY:function(t){var n=t.transforms,e=t.options;return function(t){n.rotation[1]=a.apply(void 0,e.concat([t]))}},rotateZ:s,rotate:u,scaleX:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=a.apply(void 0,e.concat([t]))}},scaleY:function(t){var n=t.transforms,e=t.options;return void 0===e&&(e=[n.scale[1],1]),function(t){n.scale[1]=a.apply(void 0,e.concat([t]))}},scale:function(t){var n=t.transforms,e=t.options;return function(t){n.scale[0]=n.scale[1]=a.apply(void 0,e.concat([t]))}},skewX:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=a.apply(void 0,e.concat([t]))}},skewY:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[1]=a.apply(void 0,e.concat([t]))}},skew:function(t){var n=t.transforms,e=t.options;return function(t){n.skew[0]=n.skew[1]=a.apply(void 0,e.concat([t]))}},fade:c,blur:f,toggle:l,stick:p});var v=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+n},easeOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(o||(o=.3*r),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+e+n},easeInOutElastic:function(t,n,e,r){var a=1.70158,o=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(o||(o=r*(.3*1.5)),i<Math.abs(e)){i=e;a=o/4}else a=o/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+e+n},easeInBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*(t/=r)*t*((a+1)*t-a)+n},easeOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),e*((t=t/r-1)*t*((a+1)*t+a)+1)+n},easeInOutBack:function(t,n,e,r,a){return null==a&&(a=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(a*=1.525))*t-a))+n:e/2*((t-=2)*t*((1+(a*=1.525))*t+a)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function d(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function M(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function m(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function w(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return M(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){M(t)},translate:function(r,a,o){return m(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,a,o),d(n,e,t),this},rotateX:function(r){var a,o;return m(t,n),o=r,(a=e)[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=Math.cos(o),a[6]=-Math.sin(o),a[7]=0,a[8]=0,a[9]=Math.sin(o),a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,d(n,e,t),this},rotateY:function(r){var a,o;return m(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=0,a[2]=Math.sin(o),a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=-Math.sin(o),a[9]=0,a[10]=Math.cos(o),a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,d(n,e,t),this},rotateZ:function(r){var a,o;return m(t,n),o=r,(a=e)[0]=Math.cos(o),a[1]=-Math.sin(o),a[2]=0,a[3]=0,a[4]=Math.sin(o),a[5]=Math.cos(o),a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,d(n,e,t),this},scale:function(r,a){return m(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),d(n,e,t),this},skew:function(r,a){return m(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,a),d(n,e,t),this}}}var y="transform",g=1,O=2,I=3;function b(t,n,e){if(void 0===n&&(n=[]),"number"==typeof t)return t;var r=window.innerWidth,a=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*r})).replace(/(\d*)vh/g,(function(t,n){return.01*n*a})).replace(/px/g,"")+");")(n,e,(function(t,n){return parseFloat(window.getComputedStyle(n)[t])||0}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)}),(function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)}))}var k=function t(n){var r=this;(n=e(n))?(n.dataset.scrollify,this.scenes=[],this.element=n,this.ticking=!1,this.active=!0,this.matrix=w(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return r.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return r.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};return k.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},k.prototype.addScene=function(t){var a=this,o=this.element,i=this.transforms,s=t.start;void 0===s&&(s="0, el.top - 100vh");var u=t.end;void 0===u&&(u="el.bottom");var c=t.easing,f=t.refs;void 0===f&&(f=[]);var l=t.effects;void 0===l&&(l={});var p=function(t,e){return Object.keys(l).reduce((function(r,a){var s,u,c,f=l[a];return n(f)?s=f:(s=h[a],c=f,u=Array.isArray(c)?f.map((function(n){return b(n,t,e)})):f),r.push(s({element:o,transforms:i,options:u})),r}),[])},d={start:0,duration:0,state:"",easing:n(c)?c:v[c],effects:[],reset:function(){var t=window.scrollY,n=r(o),i=function(t){return t.map(e).map(r)}(f),c=b(s,i,n),l=b(u,i,n),h=p(i,n);d.effects=h,d.start=c,d.duration=l-c,d.state=t>c?t>l?O:I:g,a.update(d)}};return t.skipMatrix?d.skipMatrix=!0:o.style.willChange=y,d.reset(),t.debug&&console.log("Scrollify scene: ",d),this.scenes.push(d),this},k.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},k.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},k.prototype.update=function(t){var n,e=t.start,r=t.duration,a=t.easing,o=t.effects,i=window.scrollY;if(i-e>r){if(t.state===O)return;t.state=O,n=1}else if(i-e<0){if(t.state===g)return;t.state=g,n=0}else t.state=I,n=a?a(i-e,0,1,r):(i-e)/r;o.forEach((function(t){return t(n)})),t.skipMatrix||(this.element.style.transform=this.updateMatrix().asCSS())},k.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},k.prototype.disable=function(){this.active=!1},t.Scrollify=k,t.default=k,t.easings=v,t.fx=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var Scrollify=function(t){"use strict";var n=function(t,n,e){return(n-t)*e+t},e=function(t,n){return window.getComputedStyle(n)[t]||0},r=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.max.apply(Math,t)},o=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return Math.min.apply(Math,t)},a=function(t){return"function"==typeof t},i=function(t){return 1===t.nodeType?t:document.querySelector(t)},s=function(t){var n=t.getBoundingClientRect();return{left:n.left+window.pageXOffset,right:n.right+window.pageXOffset,top:n.top+window.pageYOffset,bottom:n.bottom+window.pageYOffset,height:n.height,width:n.width}},u=function(t){var e=t.transforms,r=t.options;return function(t){e.position[0]=n.apply(void 0,r.concat([t]))}},c=function(t){var e=t.transforms,r=t.options;return function(t){e.position[1]=n.apply(void 0,r.concat([t]))}},f=c,l=function(t){var e=t.transforms,r=t.options;return function(t){e.rotation[0]=n.apply(void 0,r.concat([t]))}},p=function(t){var e=t.transforms,r=t.options;return function(t){e.rotation[1]=n.apply(void 0,r.concat([t]))}},h=function(t){var e=t.transforms,r=t.options;return function(t){e.rotation[2]=n.apply(void 0,r.concat([t]))}},d=h,v=function(t){var e=t.transforms,r=t.options;return function(t){e.scale[0]=n.apply(void 0,r.concat([t]))}},M=function(t){var e=t.transforms,r=t.options;return void 0===r&&(r=[e.scale[1],1]),function(t){e.scale[1]=n.apply(void 0,r.concat([t]))}},w=function(t){var e=t.transforms,r=t.options;return function(t){e.scale[0]=e.scale[1]=n.apply(void 0,r.concat([t]))}},y=function(t){var e=t.transforms,r=t.options;return function(t){e.skew[0]=n.apply(void 0,r.concat([t]))}},m=function(t){var e=t.transforms,r=t.options;return function(t){e.skew[1]=n.apply(void 0,r.concat([t]))}},g=function(t){var e=t.transforms,r=t.options;return function(t){e.skew[0]=e.skew[1]=n.apply(void 0,r.concat([t]))}};[u,c,l,p,h,w,v,M,g,y,m].forEach((function(t){Object.defineProperty(t,"useMatrix",{value:!0})}));var O=Object.freeze({__proto__:null,translateX:u,translateY:c,parallax:f,rotateX:l,rotateY:p,rotateZ:h,rotate:d,scaleX:v,scaleY:M,scale:w,skewX:y,skewY:m,skew:g,fade:function(t){var e=t.element,r=t.options;return function(t){e.style.opacity=n.apply(void 0,r.concat([t]))}},blur:function(t){var e=t.element,r=t.options;return function(t){e.style.filter="blur("+n.apply(void 0,r.concat([t]))+"px)"}},toggle:function(t){var n=t.element,e=t.options,r=Object.keys(e);return function(t){r.forEach((function(r){var o=e[r];n.classList.toggle(o,t>+r)}))}},stick:function(t){var n=t.element;function e(t){var e=n.__currentState;if(e!==t){if("sticky"==t){var r=n.getBoundingClientRect();n.style.top=r.top+"px",n.style.left=r.left+"px",n.style.width=r.width+"px"}else n.style.top="",n.style.left="",n.style.width="";n.classList.remove(e),n.classList.add(t),n.__currentState=t}}return function(t){e(t<=0?"normal":t>=1?"bottom":"sticky")}}});var I=Object.freeze({__proto__:null,oscillate:function(t,n,e,r){return t/=r,t=4*Math.PI*t,t=Math.sin(t)*e,(t=Math.abs(t))+n},easeInQuad:function(t,n,e,r){return e*(t/=r)*t+n},easeOutQuad:function(t,n,e,r){return-e*(t/=r)*(t-2)+n},easeInOutQuad:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t+n:-e/2*(--t*(t-2)-1)+n},easeInCubic:function(t,n,e,r){return e*(t/=r)*t*t+n},easeOutCubic:function(t,n,e,r){return e*((t=t/r-1)*t*t+1)+n},easeInOutCubic:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t+n:e/2*((t-=2)*t*t+2)+n},easeInQuart:function(t,n,e,r){return e*(t/=r)*t*t*t+n},easeOutQuart:function(t,n,e,r){return-e*((t=t/r-1)*t*t*t-1)+n},easeInOutQuart:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t+n:-e/2*((t-=2)*t*t*t-2)+n},easeInQuint:function(t,n,e,r){return e*(t/=r)*t*t*t*t+n},easeOutQuint:function(t,n,e,r){return e*((t=t/r-1)*t*t*t*t+1)+n},easeInOutQuint:function(t,n,e,r){return(t/=r/2)<1?e/2*t*t*t*t*t+n:e/2*((t-=2)*t*t*t*t+2)+n},easeInSine:function(t,n,e,r){return-e*Math.cos(t/r*(Math.PI/2))+e+n},easeOutSine:function(t,n,e,r){return e*Math.sin(t/r*(Math.PI/2))+n},easeInOutSine:function(t,n,e,r){return-e/2*(Math.cos(Math.PI*t/r)-1)+n},easeInExpo:function(t,n,e,r){return 0==t?n:e*Math.pow(2,10*(t/r-1))+n},easeOutExpo:function(t,n,e,r){return t==r?n+e:e*(1-Math.pow(2,-10*t/r))+n},easeInOutExpo:function(t,n,e,r){return 0==t?n:t==r?n+e:(t/=r/2)<1?e/2*Math.pow(2,10*(t-1))+n:e/2*(2-Math.pow(2,-10*--t))+n},easeInCirc:function(t,n,e,r){return-e*(Math.sqrt(1-(t/=r)*t)-1)+n},easeOutCirc:function(t,n,e,r){return e*Math.sqrt(1-(t=t/r-1)*t)+n},easeInOutCirc:function(t,n,e,r){return(t/=r/2)<1?-e/2*(Math.sqrt(1-t*t)-1)+n:e/2*(Math.sqrt(1-(t-=2)*t)+1)+n},easeInElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)+n},easeOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(1==(t/=r))return n+e;if(a||(a=.3*r),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return i*Math.pow(2,-10*t)*Math.sin((t*r-o)*(2*Math.PI)/a)+e+n},easeInOutElastic:function(t,n,e,r){var o=1.70158,a=0,i=e;if(0==t)return n;if(2==(t/=r/2))return n+e;if(a||(a=r*(.3*1.5)),i<Math.abs(e)){i=e;o=a/4}else o=a/(2*Math.PI)*Math.asin(e/i);return t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*-.5+n:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-o)*(2*Math.PI)/a)*.5+e+n},easeInBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*(t/=r)*t*((o+1)*t-o)+n},easeOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),e*((t=t/r-1)*t*((o+1)*t+o)+1)+n},easeInOutBack:function(t,n,e,r,o){return null==o&&(o=1.70158),(t/=r/2)<1?e/2*(t*t*((1+(o*=1.525))*t-o))+n:e/2*((t-=2)*t*((1+(o*=1.525))*t+o)+2)+n},easeOutBounce:function(t,n,e,r){return(t/=r<1/2.75)?e*(7.5625*t*t)+n:t<2/2.75?e*(7.5625*(t-=1.5/2.75)*t+.75)+n:t<2.5/2.75?e*(7.5625*(t-=2.25/2.75)*t+.9375)+n:e*(7.5625*(t-=2.625/2.75)*t+.984375)+n}});function b(t,n,e){return e[0]=t[0]*n[0]+t[1]*n[4]+t[2]*n[8]+t[3]*n[12],e[1]=t[0]*n[1]+t[1]*n[5]+t[2]*n[9]+t[3]*n[13],e[2]=t[0]*n[2]+t[1]*n[6]+t[2]*n[10]+t[3]*n[14],e[3]=t[0]*n[3]+t[1]*n[7]+t[2]*n[11]+t[3]*n[15],e[4]=t[4]*n[0]+t[5]*n[4]+t[6]*n[8]+t[7]*n[12],e[5]=t[4]*n[1]+t[5]*n[5]+t[6]*n[9]+t[7]*n[13],e[6]=t[4]*n[2]+t[5]*n[6]+t[6]*n[10]+t[7]*n[14],e[7]=t[4]*n[3]+t[5]*n[7]+t[6]*n[11]+t[7]*n[15],e[8]=t[8]*n[0]+t[9]*n[4]+t[10]*n[8]+t[11]*n[12],e[9]=t[8]*n[1]+t[9]*n[5]+t[10]*n[9]+t[11]*n[13],e[10]=t[8]*n[2]+t[9]*n[6]+t[10]*n[10]+t[11]*n[14],e[11]=t[8]*n[3]+t[9]*n[7]+t[10]*n[11]+t[11]*n[15],e[12]=t[12]*n[0]+t[13]*n[4]+t[14]*n[8]+t[15]*n[12],e[13]=t[12]*n[1]+t[13]*n[5]+t[14]*n[9]+t[15]*n[13],e[14]=t[12]*n[2]+t[13]*n[6]+t[14]*n[10]+t[15]*n[14],e[15]=t[12]*n[3]+t[13]*n[7]+t[14]*n[11]+t[15]*n[15],e}function x(t){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}function k(t,n){n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]}function S(){var t=new Float32Array(16),n=new Float32Array(16),e=new Float32Array(16);return x(t),{data:t,asCSS:function(){for(var n="matrix3d(",e=0;e<15;++e)Math.abs(t[e])<1e-4?n+="0,":n+=t[e].toFixed(10)+",";return Math.abs(t[15])<1e-4?n+="0)":n+=t[15].toFixed(10)+")",n},clear:function(){x(t)},translate:function(r,o,a){return k(t,n),function(t,n,e,r){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=n,t[13]=e,t[14]=r,t[15]=1}(e,r,o,a),b(n,e,t),this},rotateX:function(r){var o,a;return k(t,n),a=r,(o=e)[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=Math.cos(a),o[6]=-Math.sin(a),o[7]=0,o[8]=0,o[9]=Math.sin(a),o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,b(n,e,t),this},rotateY:function(r){var o,a;return k(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=0,o[2]=Math.sin(a),o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=-Math.sin(a),o[9]=0,o[10]=Math.cos(a),o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,b(n,e,t),this},rotateZ:function(r){var o,a;return k(t,n),a=r,(o=e)[0]=Math.cos(a),o[1]=-Math.sin(a),o[2]=0,o[3]=0,o[4]=Math.sin(a),o[5]=Math.cos(a),o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,b(n,e,t),this},scale:function(r,o){return k(t,n),function(t,n,e){t[0]=n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),b(n,e,t),this},skew:function(r,o){return k(t,n),function(t,n,e){t[0]=1,t[1]=Math.tan(n),t[2]=0,t[3]=0,t[4]=Math.tan(e),t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1}(e,r,o),b(n,e,t),this}}}var E="transform",_=1,P=2,C=3;function Y(t,n,a){if(void 0===n&&(n=[]),"number"==typeof t)return t;var i=window.innerWidth,s=window.innerHeight;return new Function("refs","el","css","min","max","'use strict';return ("+t.replace(/(\d*)vw/g,(function(t,n){return.01*n*i})).replace(/(\d*)vh/g,(function(t,n){return.01*n*s})).replace(/px/g,"")+");")(n,a,e,r,o)}var Q=function t(n){var e=this;(n=i(n))?(n.dataset.scrollify,this.scenes=[],this.element=n,this.ticking=!1,this.active=!0,this.matrix=S(),this.transforms={scale:[1,1],rotation:[0,0,0],position:[0,0,0]},window.addEventListener("scroll",(function(){return e.onScroll()}),{passive:!0}),window.addEventListener("resize",(function(){return e.onResize()}),{passive:!0})):document.querySelectorAll("[data-scrollify]").forEach((function(n){return new t(n)}))};return Q.prototype.parseDataAttribute=function(t){var n;return n=t.dataset.scrollify,Function("'use strict';return ("+n+")")()},Q.prototype.addScene=function(t){var n=this,e=this.element,r=this.transforms,o=t.start;void 0===o&&(o="0, el.top - 100vh");var u=t.end;void 0===u&&(u="el.bottom");var c=t.easing,f=t.refs;void 0===f&&(f=[]);var l=t.effects;void 0===l&&(l={});var p=!1,h=function(t,n){return Object.keys(l).reduce((function(o,i){var s,u,c,f=l[i];return a(f)?s=f:(s=O[i],c=f,u=Array.isArray(c)?f.map((function(e){return Y(e,t,n)})):f),p=p||s.useMatrix,o.push(s({element:e,transforms:r,options:u})),o}),[])},d={start:0,duration:0,state:"",easing:a(c)?c:I[c],effects:[],reset:function(){var t=window.scrollY,r=s(e),a=function(t){return t.map(i).map(s)}(f),c=Y(o,a,r),l=Y(u,a,r),v=h(a,r);d.effects=v,d.start=c,d.duration=l-c,d.state=t>c?t>l?P:C:_,d.useMatrix=p,n.update(d)}};return d.reset(),p&&(e.style.willChange=E),t.debug&&console.log("Scrollify scene: ",d),this.scenes.push(d),this},Q.prototype.onScroll=function(){var t=this;this.active&&window.requestAnimationFrame((function(){t.scenes.forEach((function(n){return t.update(n)}),t)}))},Q.prototype.onResize=function(){this.scenes.forEach((function(t){return t.reset()}))},Q.prototype.update=function(t){var n,e=t.start,r=t.duration,o=t.easing,a=t.effects,i=window.scrollY;if(i-e>r){if(t.state===P)return;t.state=P,n=1}else if(i-e<0){if(t.state===_)return;t.state=_,n=0}else t.state=C,n=o?o(i-e,0,1,r):(i-e)/r;a.forEach((function(t){return t(n)})),t.useMatrix&&(this.element.style.transform=this.updateMatrix().asCSS())},Q.prototype.updateMatrix=function(){var t=this.matrix,n=this.transforms;return t.clear(),n.transformOrigin&&t.translate(-n.transformOrigin[0],-n.transformOrigin[1],-n.transformOrigin[2]),n.scale&&t.scale(n.scale[0],n.scale[1]),n.skew&&t.skew(n.skew[0],n.skew[1]),n.rotation&&(t.rotateX(n.rotation[0]),t.rotateY(n.rotation[1]),t.rotateZ(n.rotation[2])),n.position&&t.translate(n.position[0],n.position[1],n.position[2]),n.transformOrigin&&t.translate(n.transformOrigin[0],n.transformOrigin[1],n.transformOrigin[2]),t},Q.prototype.disable=function(){this.active=!1},t.Scrollify=Q,t.default=Q,t.easings=I,t.fx=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.2-alpha", | ||
"version": "1.0.3-alpha", | ||
"description": "A simple thing for triggering 'them scroll effects that everybody loves", | ||
@@ -8,0 +8,0 @@ "homepage": "https://github.com/apathetic/scrollify", |
@@ -18,3 +18,3 @@ /** | ||
const lerp = (start, end, t) => (end - start) * t + start; | ||
import { lerp } from './utils'; | ||
@@ -190,6 +190,13 @@ | ||
// Effects that do _not_ use matrix transformations. | ||
[stick, toggle, blur, fade].forEach((fn) => { | ||
Object.defineProperty(fn, 'skipMatrix', { value: true }); | ||
// [stick, toggle, blur, fade].forEach((fn) => { | ||
// Object.defineProperty(fn, 'skipMatrix', { value: true }); | ||
// }); | ||
// Effects that use matrix transformations. At present, only | ||
// built-in effects benefit from matrix transformations. | ||
[translateX, translateY, rotateX, rotateY, rotateZ, scale, scaleX, scaleY, skew, skewX, skewY].forEach((fn) => { | ||
// Object.defineProperty(fn, '__applyTransform', { value: true }); | ||
Object.defineProperty(fn, 'useMatrix', { value: true }); | ||
}); | ||
@@ -10,3 +10,3 @@ /* | ||
import { getRef, getPosition, isFunc, isArray } from './utils'; | ||
import { getRef, getPosition, isFunc, isArray, css, min, max } from './utils'; | ||
import * as Effects from './effects'; | ||
@@ -58,14 +58,11 @@ import * as Easings from './easings'; | ||
// helper parsing functions | ||
// NOTE: will work for --css-vars, but only if they resolve to a number (ie. no strings, 'rgb(0,0,0)' etc): | ||
// const css = (prop, el) => parseFloat(window.getComputedStyle(el).getPropertyValue(prop)) || 0; | ||
// /** var(--top-spacing) **/ | ||
// function var(str) { | ||
// // ... returns a CSS var ie --top-padding | ||
// } | ||
// const css = (prop, el) => parseFloat(window.getComputedStyle(el)[prop]) || 0; | ||
// const max = (...args) => Math.max(...args); | ||
// const min = (...args) => Math.min(...args); | ||
// helper parsing functions | ||
const css = (prop, el) => parseFloat(window.getComputedStyle(el)[prop]) || 0; | ||
const max = (...args) => Math.max(...args); | ||
const min = (...args) => Math.min(...args); | ||
// with (css) { | ||
return new Function('refs', 'el', 'css', 'min', 'max', `'use strict';return (${val | ||
@@ -76,7 +73,36 @@ .replace(/(\d*)vw/g, (match, v) => .01 * v * screenWidth) | ||
});`)(refs, el, css, max, min); | ||
// } | ||
} | ||
/** | ||
* Calculate the start point of each scene. | ||
* @param {HTMLElement} trigger .... | ||
* @return {number} The start position of the Scene, in pixels. | ||
*/ | ||
function calculateStart(trigger, offset = 0) { | ||
const c = window.innerHeight - (offset * window.innerHeight); | ||
const top = trigger ? trigger.getBoundingClientRect().top + window.pageYOffset : 0; | ||
return Math.max(0, top - c); | ||
} | ||
/* | ||
* @example "0.5" | ||
* @example "200px" | ||
* @example "33vh" | ||
* @example "(el, refs) => refs[3].bottom - css(padding-top, refs[0]) - css(top, refs[0])", | ||
* @example "(el, refs) => max((100vh / refs[2].height), (100vw / refs[2].width)) + 0.02" | ||
*/ | ||
function calculateDuration(d = 1, el) { | ||
return (typeof d === 'function') ? | ||
d(el) : | ||
mapTo(d, window.innerHeight + el.offsetHeight); | ||
} | ||
// | ||
/** | ||
@@ -172,2 +198,4 @@ * The Scrollify Class | ||
let useMatrix = false; | ||
// const calculateEffects = (r, el) => Object.keys(effects).reduce(this.addEffect, []); | ||
@@ -186,2 +214,3 @@ const calculateEffects = (r, el) => Object.keys(effects).reduce((fx, name) => { | ||
useMatrix = useMatrix || fn.useMatrix; | ||
fx.push(fn({ element, transforms, options })); | ||
@@ -211,2 +240,5 @@ | ||
// internal-use only. Whether to use matrix transforms or not. | ||
scene.useMatrix = useMatrix; // || data.skipMatrix // force override | ||
this.update(scene); | ||
@@ -216,11 +248,12 @@ } | ||
if (data.skipMatrix) { | ||
// scene.skipMatrix = scene.effects.every((fn) => fn.skipMatrix); | ||
// internal-use only. Whether to use matrix transforms or not. | ||
scene.skipMatrix = true; | ||
} else { | ||
scene.reset(); | ||
if (useMatrix) { | ||
// scene.useMatrix = true; | ||
element.style.willChange = transform; | ||
// } else { | ||
// // internal-use only. Whether to use matrix transforms or not. | ||
// scene.useMatrix = false; | ||
} | ||
scene.reset(); | ||
@@ -330,6 +363,6 @@ if (data.debug) { | ||
if (scene.skipMatrix) { return; } | ||
// transmogrify all applied transformations into a single matrix, and apply | ||
this.element.style[transform] = this.updateMatrix().asCSS(); | ||
if (scene.useMatrix) { | ||
// transmogrify all applied transformations into a single matrix, and apply | ||
this.element.style[transform] = this.updateMatrix().asCSS(); | ||
} | ||
} | ||
@@ -336,0 +369,0 @@ |
@@ -46,7 +46,12 @@ | ||
export const lerp = (start, end, t) => (end - start) * t + start; | ||
// export const css = (prop, el) => parseFloat(window.getComputedStyle(el)[prop]) || 0; | ||
// export const css = (prop, el) => parseFloat(window.getComputedStyle(el).getPropertyValue(prop)) || 0; | ||
export const css = (prop, el) => window.getComputedStyle(el)[prop] || 0; | ||
export const max = (...args) => Math.max(...args); | ||
export const min = (...args) => Math.min(...args); | ||
export const isArray = (n) => Array.isArray(n); | ||
export const isFunc = (n) => typeof n === 'function'; | ||
export const getRef = (el) => el.nodeType === 1 ? el : document.querySelector(el); | ||
export const getRef = (el) => el instanceof HTMLElement ? el : document.querySelector(el); | ||
export const getPosition = (el) => { | ||
@@ -63,1 +68,3 @@ const bcr = el.getBoundingClientRect(); | ||
}; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73613
1149