perspective.js
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -1,1 +0,1 @@ | ||
"use strict";function iterativelyWalk(e,t){"length"in e||(e=[e]),e=slice.call(e);for(;e.length;){var n=e.shift(),r=t(n);if(r)return r;n.childNodes&&n.childNodes.length&&(e=slice.call(n.childNodes).concat(e))}}function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function buildGraph(){for(var e={},t=models$1.length,n=0;n<t;n++)e[models$1[n]]={distance:-1,parent:null};return e}function deriveBFS(e){var t=buildGraph(),n=[e];for(t[e].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(conversions$3[r]),i=a.length,o=0;o<i;o++){var s=a[o],l=t[s];l.distance===-1&&(l.distance=t[r].distance+1,l.parent=r,n.unshift(s))}return t}function link(e,t){return function(n){return t(e(n))}}function wrapConversion(e,t){for(var n=[t[e].parent,e],r=conversions$3[t[e].parent][e],a=t[e].parent;t[a].parent;)n.unshift(t[a].parent),r=link(conversions$3[t[a].parent][a],r),a=t[a].parent;return r.conversion=n,r}function wrapRaw(e){var t=function(t){return void 0===t||null===t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function wrapRounded(e){var t=function(t){if(void 0===t||null===t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var n=e(t);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in e&&(t.conversion=e.conversion),t}Object.defineProperty(exports,"__esModule",{value:!0});var slice=Array.prototype.slice,index=iterativelyWalk,getObjectFromArrById=function(e,t){for(var n,r=0,a=e.length;r<a;r++){var i=e[r];if(i.id===t){n=i;break}}if(n)return n;throw new Error("Cannot find "+t+" id in "+JSON.stringify(e))},is=function(e){var t={hsl:new RegExp(/^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*[\d\.]+)?\s*\)$/),hex:new RegExp(/^#[a-f0-9]{3}([a-f0-9]{3})?$/,"i")};for(var n in t)if(t.hasOwnProperty(n)&&t[n].test(e))return n},merge=function(e,t){for(var n=0,r=t.length;n<r;n++){var a=t[n]||{};for(var i in a)if(a.hasOwnProperty(i)){var o=a[i];void 0!==o&&(e[i]=o)}}return e},defaultConfig={layers:[],max:20,reverse:!1,perspective:1e3,easing:"cubic-bezier(.03, .98, .52, .99)",scale:"1",speed:"300",disabledAxis:null,reset:!0},Hover=function(e,t){var n=this;if("string"==typeof e&&(e=document.querySelector(e)),!e||1!==e.nodeType)throw new Error("Cannot find target dom to apply hover effects");t=merge({},[defaultConfig,t]),this.target=e,this.config=t,this.layers=[],index(e,function(e){if(1===e.nodeType){var r=e.getAttribute("data-hover-layer");if(r){var a=t.layers[Number(r)].speed;if(!a)throw new Error("Missing translate config for "+r);n.layers.push(merge({node:e,speed:void 0===a?.2:a,reverse:!!t.layers[Number(r)].reverse},[n.constructor.getInitialTransformMatrix(e)]))}}}),this.target.style.transform="perspective("+this.config.perspective+"px)",this.addEventHandlers()};Hover.getInitialTransformMatrix=function(e){var t=window.getComputedStyle(e).transform.match(/matrix.*\((.*)\)/),n=[1,0,0,1,0,0],r=4,a=5;return t&&t[1]&&(n=t[1].split(/\s*\,\s*/)),16===n.length&&(r=12,a=13),{matrixArr:n,translateXIndex:r,translateYIndex:a}},Hover.prototype.addEventHandlers=function(){this.target.addEventListener("mouseenter",this.onMouseEnter.bind(this)),this.target.addEventListener("mousemove",this.onMouseMove.bind(this)),this.target.addEventListener("mouseleave",this.onMouseLeave.bind(this))},Hover.prototype.doTranslate=function(e,t,n){var r=["webkitTransform","msTransform","mozTransform","transform"],a=e.node,i=e.matrixArr,o=e.translateXIndex,s=e.translateYIndex,l=i.slice();l[o]=Number(l[o])+t,l[s]=Number(l[s])+n;var c=l.join(", ");r.forEach(function(e){a.style[e]=(6===i.length?"matrix":"matrix3d")+"("+c+")"})},Hover.prototype.translateLayers=function(e,t,n){var r=e.speed,a=e.reverse,i=Math.floor(r*(.5*document.body.clientWidth+(a?-1:1)*t)),o=Math.floor(r*(.5*document.body.clientHeight+(a?-1:1)*n));this.doTranslate(e,i,o)},Hover.prototype.getValues=function(e){var t=(e.pageX-this.left)/this.width,n=(e.pageY-this.top)/this.height;t=Math.min(Math.max(t,0),1),n=Math.min(Math.max(n,0),1);var r=(this.config.reverse?-1:1)*(this.config.max/2-t*this.config.max).toFixed(2),a=(this.config.reverse?-1:1)*(n*this.config.max-this.config.max/2).toFixed(2);return{tiltX:r,tiltY:a}},Hover.prototype.setTransition=function(){var e=this;clearTimeout(this.transitionTimeout),this.target.style.transition=this.config.speed+"ms "+this.config.easing,this.transitionTimeout=setTimeout(function(t){e.target.style.transition=""},this.config.speed)},Hover.prototype.onMouseEnter=function(e){var t=this;this.width=this.target.offsetWidth,this.height=this.target.offsetHeight,this.left=this.target.offsetLeft,this.top=this.target.offsetTop,this.setTransition(),this.layers.forEach(function(n){n.node.style.transition=t.config.speed+"ms "+t.config.easing,t.translateLayers(n,e.clientX,e.clientY)}),setTimeout(function(){t.layers.forEach(function(e){var t=e.node;t.style.transition="none"})},this.config.speed)},Hover.prototype.onMouseMove=function(e){var t=this,n=this.getValues(e);this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX("+("x"===this.config.disabledAxis?0:n.tiltY)+"deg)\n rotateY("+("y"===this.config.disabledAxis?0:n.tiltX)+"deg)\n scale3d("+this.config.scale+", "+this.config.scale+", "+this.config.scale+")\n ",window.requestAnimationFrame(function(n){t.layers.forEach(function(n){t.translateLayers(n,e.clientX,e.clientY)})})},Hover.prototype.onMouseLeave=function(){var e=this;this.config.reset===!0&&(this.setTransition(),this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX(0deg)\n rotateY(0deg)\n scale3d(1, 1, 1)\n ",this.layers.forEach(function(t){t.node.style.transition=e.config.speed+"ms "+e.config.easing,e.doTranslate(t,0,0)}))};var index$2={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},conversions$1=createCommonjsModule(function(e){function t(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2)}var n=index$2,r={};for(var a in n)n.hasOwnProperty(a)&&(r[n[a]]=a);var i=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var o in i)if(i.hasOwnProperty(o)){if(!("channels"in i[o]))throw new Error("missing channels property: "+o);if(!("labels"in i[o]))throw new Error("missing channel labels property: "+o);if(i[o].labels.length!==i[o].channels)throw new Error("channel and label counts mismatch: "+o);var s=i[o].channels,l=i[o].labels;delete i[o].channels,delete i[o].labels,Object.defineProperty(i[o],"channels",{value:s}),Object.defineProperty(i[o],"labels",{value:l})}i.rgb.hsl=function(e){var t,n,r,a=e[0]/255,i=e[1]/255,o=e[2]/255,s=Math.min(a,i,o),l=Math.max(a,i,o),c=l-s;return l===s?t=0:a===l?t=(i-o)/c:i===l?t=2+(o-a)/c:o===l&&(t=4+(a-i)/c),t=Math.min(60*t,360),t<0&&(t+=360),r=(s+l)/2,n=l===s?0:r<=.5?c/(l+s):c/(2-l-s),[t,100*n,100*r]},i.rgb.hsv=function(e){var t,n,r,a=e[0],i=e[1],o=e[2],s=Math.min(a,i,o),l=Math.max(a,i,o),c=l-s;return n=0===l?0:c/l*1e3/10,l===s?t=0:a===l?t=(i-o)/c:i===l?t=2+(o-a)/c:o===l&&(t=4+(a-i)/c),t=Math.min(60*t,360),t<0&&(t+=360),r=l/255*1e3/10,[t,n,r]},i.rgb.hwb=function(e){var t=e[0],n=e[1],r=e[2],a=i.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[a,100*o,100*r]},i.rgb.cmyk=function(e){var t,n,r,a,i=e[0]/255,o=e[1]/255,s=e[2]/255;return a=Math.min(1-i,1-o,1-s),t=(1-i-a)/(1-a)||0,n=(1-o-a)/(1-a)||0,r=(1-s-a)/(1-a)||0,[100*t,100*n,100*r,100*a]},i.rgb.keyword=function(e){var a=r[e];if(a)return a;var i,o=1/0;for(var s in n)if(n.hasOwnProperty(s)){var l=n[s],c=t(e,l);c<o&&(o=c,i=s)}return i},i.keyword.rgb=function(e){return n[e]},i.rgb.xyz=function(e){var t=e[0]/255,n=e[1]/255,r=e[2]/255;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;var a=.4124*t+.3576*n+.1805*r,i=.2126*t+.7152*n+.0722*r,o=.0193*t+.1192*n+.9505*r;return[100*a,100*i,100*o]},i.rgb.lab=function(e){var t,n,r,a=i.rgb.xyz(e),o=a[0],s=a[1],l=a[2];return o/=95.047,s/=100,l/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,t=116*s-16,n=500*(o-s),r=200*(s-l),[t,n,r]},i.hsl.rgb=function(e){var t,n,r,a,i,o=e[0]/360,s=e[1]/100,l=e[2]/100;if(0===s)return i=255*l,[i,i,i];n=l<.5?l*(1+s):l+s-l*s,t=2*l-n,a=[0,0,0];for(var c=0;c<3;c++)r=o+1/3*-(c-1),r<0&&r++,r>1&&r--,i=6*r<1?t+6*(n-t)*r:2*r<1?n:3*r<2?t+(n-t)*(2/3-r)*6:t,a[c]=255*i;return a},i.hsl.hsv=function(e){var t,n,r=e[0],a=e[1]/100,i=e[2]/100,o=a,s=Math.max(i,.01);return i*=2,a*=i<=1?i:2-i,o*=s<=1?s:2-s,n=(i+a)/2,t=0===i?2*o/(s+o):2*a/(i+a),[r,100*t,100*n]},i.hsv.rgb=function(e){var t=e[0]/60,n=e[1]/100,r=e[2]/100,a=Math.floor(t)%6,i=t-Math.floor(t),o=255*r*(1-n),s=255*r*(1-n*i),l=255*r*(1-n*(1-i));switch(r*=255,a){case 0:return[r,l,o];case 1:return[s,r,o];case 2:return[o,r,l];case 3:return[o,s,r];case 4:return[l,o,r];case 5:return[r,o,s]}},i.hsv.hsl=function(e){var t,n,r,a=e[0],i=e[1]/100,o=e[2]/100,s=Math.max(o,.01);return r=(2-i)*o,t=(2-i)*s,n=i*s,n/=t<=1?t:2-t,n=n||0,r/=2,[a,100*n,100*r]},i.hwb.rgb=function(e){var t,n,r,a,i=e[0]/360,o=e[1]/100,s=e[2]/100,l=o+s;l>1&&(o/=l,s/=l),t=Math.floor(6*i),n=1-s,r=6*i-t,0!==(1&t)&&(r=1-r),a=o+r*(n-o);var c,h,u;switch(t){default:case 6:case 0:c=n,h=a,u=o;break;case 1:c=a,h=n,u=o;break;case 2:c=o,h=n,u=a;break;case 3:c=o,h=a,u=n;break;case 4:c=a,h=o,u=n;break;case 5:c=n,h=o,u=a}return[255*c,255*h,255*u]},i.cmyk.rgb=function(e){var t,n,r,a=e[0]/100,i=e[1]/100,o=e[2]/100,s=e[3]/100;return t=1-Math.min(1,a*(1-s)+s),n=1-Math.min(1,i*(1-s)+s),r=1-Math.min(1,o*(1-s)+s),[255*t,255*n,255*r]},i.xyz.rgb=function(e){var t,n,r,a=e[0]/100,i=e[1]/100,o=e[2]/100;return t=3.2406*a+i*-1.5372+o*-.4986,n=a*-.9689+1.8758*i+.0415*o,r=.0557*a+i*-.204+1.057*o,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,t=Math.min(Math.max(0,t),1),n=Math.min(Math.max(0,n),1),r=Math.min(Math.max(0,r),1),[255*t,255*n,255*r]},i.xyz.lab=function(e){var t,n,r,a=e[0],i=e[1],o=e[2];return a/=95.047,i/=100,o/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,t=116*i-16,n=500*(a-i),r=200*(i-o),[t,n,r]},i.lab.xyz=function(e){var t,n,r,a=e[0],i=e[1],o=e[2];n=(a+16)/116,t=i/500+n,r=n-o/200;var s=Math.pow(n,3),l=Math.pow(t,3),c=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,t=l>.008856?l:(t-16/116)/7.787,r=c>.008856?c:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},i.lab.lch=function(e){var t,n,r,a=e[0],i=e[1],o=e[2];return t=Math.atan2(o,i),n=360*t/2/Math.PI,n<0&&(n+=360),r=Math.sqrt(i*i+o*o),[a,r,n]},i.lch.lab=function(e){var t,n,r,a=e[0],i=e[1],o=e[2];return r=o/360*2*Math.PI,t=i*Math.cos(r),n=i*Math.sin(r),[a,t,n]},i.rgb.ansi16=function(e){var t=e[0],n=e[1],r=e[2],a=1 in arguments?arguments[1]:i.rgb.hsv(e)[2];if(a=Math.round(a/50),0===a)return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(t/255));return 2===a&&(o+=60),o},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){var t=e[0],n=e[1],r=e[2];if(t===n&&n===r)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;var a=16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5);return a},i.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];var n=.5*(~~(e>50)+1),r=(1&t)*n*255,a=(t>>1&1)*n*255,i=(t>>2&1)*n*255;return[r,a,i]},i.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}e-=16;var n,r=Math.floor(e/36)/5*255,a=Math.floor((n=e%36)/6)/5*255,i=n%6/5*255;return[r,a,i]},i.rgb.hex=function(e){var t=((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2])),n=t.toString(16).toUpperCase();return"000000".substring(n.length)+n},i.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var n=t[0];3===t[0].length&&(n=n.split("").map(function(e){return e+e}).join(""));var r=parseInt(n,16),a=r>>16&255,i=r>>8&255,o=255&r;return[a,i,o]},i.rgb.hcg=function(e){var t,n,r=e[0]/255,a=e[1]/255,i=e[2]/255,o=Math.max(Math.max(r,a),i),s=Math.min(Math.min(r,a),i),l=o-s;return t=l<1?s/(1-l):0,n=l<=0?0:o===r?(a-i)/l%6:o===a?2+(i-r)/l:4+(r-a)/l+4,n/=6,n%=1,[360*n,100*l,100*t]},i.hsl.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=1,a=0;return r=n<.5?2*t*n:2*t*(1-n),r<1&&(a=(n-.5*r)/(1-r)),[e[0],100*r,100*a]},i.hsv.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=t*n,a=0;return r<1&&(a=(n-r)/(1-r)),[e[0],100*r,100*a]},i.hcg.rgb=function(e){var t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];var a=[0,0,0],i=t%1*6,o=i%1,s=1-o,l=0;switch(Math.floor(i)){case 0:a[0]=1,a[1]=o,a[2]=0;break;case 1:a[0]=s,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=o;break;case 3:a[0]=0,a[1]=s,a[2]=1;break;case 4:a[0]=o,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=s}return l=(1-n)*r,[255*(n*a[0]+l),255*(n*a[1]+l),255*(n*a[2]+l)]},i.hcg.hsv=function(e){var t=e[1]/100,n=e[2]/100,r=t+n*(1-t),a=0;return r>0&&(a=t/r),[e[0],100*a,100*r]},i.hcg.hsl=function(e){var t=e[1]/100,n=e[2]/100,r=n*(1-t)+.5*t,a=0;return r>0&&r<.5?a=t/(2*r):r>=.5&&r<1&&(a=t/(2*(1-r))),[e[0],100*a,100*r]},i.hcg.hwb=function(e){var t=e[1]/100,n=e[2]/100,r=t+n*(1-t);return[e[0],100*(r-t),100*(1-r)]},i.hwb.hcg=function(e){var t=e[1]/100,n=e[2]/100,r=1-n,a=r-t,i=0;return a<1&&(i=(r-a)/(1-a)),[e[0],100*a,100*i]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=i.gray.hsv=function(e){return[0,0,e[0]]},i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),n=(t<<16)+(t<<8)+t,r=n.toString(16).toUpperCase();return"000000".substring(r.length)+r},i.rgb.gray=function(e){var t=(e[0]+e[1]+e[2])/3;return[t/255*100]}}),conversions$3=conversions$1,models$1=Object.keys(conversions$3),route$1=function(e){for(var t=deriveBFS(e),n={},r=Object.keys(t),a=r.length,i=0;i<a;i++){var o=r[i],s=t[o];null!==s.parent&&(n[o]=wrapConversion(o,t))}return n},conversions=conversions$1,route=route$1,convert={},models=Object.keys(conversions);models.forEach(function(e){convert[e]={},Object.defineProperty(convert[e],"channels",{value:conversions[e].channels}),Object.defineProperty(convert[e],"labels",{value:conversions[e].labels});var t=route(e),n=Object.keys(t);n.forEach(function(n){var r=t[n];convert[e][n]=wrapRounded(r),convert[e][n].raw=wrapRaw(r)})});var index$1=convert,throttle=function(e,t,n,r){function a(){function a(){o=Number(new Date),n.apply(l,h)}function s(){i=void 0}var l=this,c=Number(new Date)-o,h=arguments;r&&!i&&a(),i&&clearTimeout(i),void 0===r&&c>e?a():t!==!0&&(i=setTimeout(r?s:a,void 0===r?e-c:e))}var i,o=0;return"boolean"!=typeof t&&(r=n,n=t,t=void 0),a},defaultConfig$1={stageSwitchTransition:800,stageSwitchDelay:0,stageSwitchEasing:"cubic-bezier(.86, 0, .07, 1)",disableAfterSwitching:500,stages:[]},defaultStageConfig={scrollNumber:1,transition:200,easing:"ease",items:[]},numberRegExp=new RegExp(/-?\d+(?:\.\d+)?/,"g"),vendors=["webkit","ms","moz",""],Scroll=function(e,t){if("string"==typeof e&&(e=document.querySelector(e)),!e||1!==e.nodeType)throw new Error("Cannot find target dom to apply scroll effects");t=merge({},[defaultConfig$1,t]),e.style.overflow="hidden",this.target=e,this.config=t,this.animating=!1,this.switching=!1,this.stages=[],this.activeStageIndex=0,this.initStages(),this.processStages(),this.defineActiveStage(),this.addEventListeners()};Scroll.prototype.defineActiveStage=function(){var e=this.stages[this.activeStageIndex],t=this;Object.defineProperty(this,"activeStage",{get:function(){return e},set:function(n){if(n!==e){var r=JSON.parse(JSON.stringify(e));e=n,t.activeStageIndex=t.stages.findIndex(function(e){return e===n}),t.handleActiveStageChange(),t.target.dispatchEvent(new CustomEvent("stage-change",{detail:{previous:{id:r.id,node:r.node,config:r.stageConfig,step:r.step},current:{id:n.id,node:n.node,config:n.stageConfig}}}))}}})},Scroll.prototype.addEventListeners=function(){this.boundHandleScroll=this.handleScroll.bind(this),this.throttledHandleStepChange=throttle(50,!0,this.handleStepChange,!0),document.addEventListener("wheel",this.boundHandleScroll)},Scroll.prototype.removeEventListeners=function(){document.removeEventListener("wheel",this.boundHandleScroll)},Scroll.prototype.initStages=function(){var e=this;index(this.target,function(t){if(1===t.nodeType){var n=t.getAttribute("data-scroll-stage-id");if(n){var r=getObjectFromArrById(e.config.stages,n);if(!r)throw new Error("\n Missing scrolling config for stage id: "+n+"\n ");t.style.transition="\n "+e.config.stageSwitchTransition+"ms "+e.config.stageSwitchEasing+" "+e.config.stageSwitchDelay+"ms\n ",e.stages.push({node:t,stageConfig:merge({},[defaultStageConfig,r]),id:n,step:0})}}})},Scroll.prototype.processStages=function(){var e=this;this.stages.forEach(function(t){e.constructor.attachNodeToItems(t),e.processItemEffects(t)})},Scroll.attachNodeToItems=function(e){index(e.node,function(t){if(1===t.nodeType){var n=t.getAttribute("data-scroll-item-id");if(n){var r=getObjectFromArrById(e.stageConfig.items,n);if(!r)throw new Error("Missing scrolling config for item id: "+n);r.node=t}}})},Scroll.prototype.processItemEffects=function(e){var t=this;e.stageConfig.items.forEach(function(n){n.effects.forEach(function(n){void 0===n.startAt&&(n.startAt=0),void 0===n.endAt&&(n.endAt=Number(e.stageConfig.scrollNumber)),t.constructor.processColorValues(n),n.startNumbers=(n.start.match(numberRegExp)||[]).map(function(e){return Number(e)}),n.endNumbers=(n.end.match(numberRegExp)||[]).map(function(e){return Number(e)}),n.strings=n.start.split(numberRegExp)})})},Scroll.getCurrentStyleValue=function(e,t){var n=e.startAt,r=e.endAt,a=e.startNumbers,i=e.endNumbers,o=e.strings,s=e.isColor;t=Math.min(r,Math.max(n,t));var l=o[0],c=-1;return a&&a.length>0&&a.forEach(function(e,a){/rgba/.test(o[a])&&(c=a+3);var h=e+(t-n)*(i[a]-e)/(r-n);s&&a!==c&&(h=Math.round(h)),l+=""+h+o[a+1]}),l},Scroll.processColorValues=function(e){["start","end"].forEach(function(t){var n=e[t],r=is(n);if(r){if(e.isColor=!0,"hex"===r)n="\n rgb("+index$1.hex.rgb(n).join(",")+")\n ";else if("hsl"===r){var a=n.match(/hsla?\((.*)\)/)[1].split(/\s*,\s*/).map(function(e){return parseFloat(e)}),i=a[0],o=a[1],s=a[2],l=a[3];n="\n rgba("+index$1.hsl.rgb([i,o,s]).join(",")+", "+(void 0===l?1:l)+")\n "}e[t]=n}})},Scroll.prototype.setActiveStage=function(e,t){if(void 0===t&&(t=!1),this.activeStage.id!==e){var n=this.activeStageIndex;this.activeStage.step=0;var r=getObjectFromArrById(this.stages,e)||this.stages[0],a=this.stages.findIndex(function(e){return e===r});t?(r.step=n<a?0:Number(r.stageConfig.scrollNumber),this.activeStage=r,this.handleStepChange(!1,!1)):(this.activeStage=r,this.handleStepChange(!1,!1))}},Scroll.prototype.handleActiveStageChange=function(){var e=this;clearTimeout(this.switchingTimeout),this.switching=!0,this.stages.forEach(function(t){vendors.forEach(function(n){var r=n.length?n+"Transform":"transform";t.node.style[r]="translateY("+100*-e.activeStageIndex+"%)"})}),this.switchingTimeout=setTimeout(function(t){e.switching=!1},Number(this.config.stageSwitchTransition)+Number(this.config.disableAfterSwitching))},Scroll.prototype.setStep=function(e){var t=typeof e;if("number"!==t)throw new Error("step should be not a number, got "+t);if(e<0||e>Number(this.activeStage.stageConfig.scrollNumber))throw new Error("\n step should be within [0, "+this.activeStage.stageConfig.scrollNumber+"], got "+e+"\n ");this.activeStage.step!==e&&(this.activeStage.step=e,this.handleStepChange())},Scroll.prototype.getActiveStage=function(){return this.activeStage},Scroll.prototype.getStep=function(){return this.activeStage.step},Scroll.prototype.handleStepChange=function(e,t){var n=this;void 0===e&&(e=!0),void 0===t&&(t=!0);var r=this.activeStage.step,a=this.activeStage.stageConfig,i=this.activeStageIndex;if(r>Number(a.scrollNumber)){if(i===this.stages.length-1)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"bottom"}})),void(this.activeStage.step=Number(a.scrollNumber));this.setActiveStage(this.stages[i+1].id,!0)}else if(r<0){if(0===i)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"top"}})),void(this.activeStage.step=0);this.setActiveStage(this.stages[i-1].id,!0)}else clearTimeout(this.animatingTimeout),this.animating=!0,a.items.forEach(function(t){t.node.style.transition=e?a.transition+"ms "+a.easing:"none",t.effects.forEach(function(e){t.node.style[e.property]=n.constructor.getCurrentStyleValue(e,r)})}),t&&this.target.dispatchEvent(new CustomEvent("step-change",{detail:{activeStage:{id:this.activeStage.id,node:this.activeStage.node,config:a},current:r}})),this.animatingTimeout=setTimeout(function(e){n.animating=!1},e?Number(a.transition):0)},Scroll.prototype.handleScroll=function(e){e.preventDefault(),this.animating||this.switching||(this.activeStage.step+=e.deltaY>0?1:-1,this.throttledHandleStepChange())},exports.Hover=Hover,exports.Scroll=Scroll; | ||
"use strict";function iterativelyWalk(e,t){"length"in e||(e=[e]),e=slice.call(e);for(;e.length;){var r=e.shift(),n=t(r);if(n)return n;r.childNodes&&r.childNodes.length&&(e=slice.call(r.childNodes).concat(e))}}function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function buildGraph(){for(var e={},t=models$1.length,r=0;r<t;r++)e[models$1[r]]={distance:-1,parent:null};return e}function deriveBFS(e){var t=buildGraph(),r=[e];for(t[e].distance=0;r.length;)for(var n=r.pop(),i=Object.keys(conversions$3[n]),a=i.length,o=0;o<a;o++){var s=i[o],l=t[s];l.distance===-1&&(l.distance=t[n].distance+1,l.parent=n,r.unshift(s))}return t}function link(e,t){return function(r){return t(e(r))}}function wrapConversion(e,t){for(var r=[t[e].parent,e],n=conversions$3[t[e].parent][e],i=t[e].parent;t[i].parent;)r.unshift(t[i].parent),n=link(conversions$3[t[i].parent][i],n),i=t[i].parent;return n.conversion=r,n}function wrapRaw(e){var t=function(t){return void 0===t||null===t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function wrapRounded(e){var t=function(t){if(void 0===t||null===t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var r=e(t);if("object"==typeof r)for(var n=r.length,i=0;i<n;i++)r[i]=Math.round(r[i]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}Object.defineProperty(exports,"__esModule",{value:!0});var slice=Array.prototype.slice,index=iterativelyWalk,getObjectFromArrById=function(e,t){for(var r,n=0,i=e.length;n<i;n++){var a=e[n];if(a.id===t){r=a;break}}if(r)return r;throw new Error("Cannot find "+t+" id in "+JSON.stringify(e))},is=function(e){var t={hsl:new RegExp(/^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*[\d\.]+)?\s*\)$/),hex:new RegExp(/^#[a-f0-9]{3}([a-f0-9]{3})?$/,"i")};for(var r in t)if(t.hasOwnProperty(r)&&t[r].test(e))return r},merge=function(e,t){for(var r=0,n=t.length;r<n;r++){var i=t[r]||{};for(var a in i)if(i.hasOwnProperty(a)){var o=i[a];void 0!==o&&(e[a]=o)}}return e},defaultConfig={layers:[],max:20,reverseTilt:!1,perspective:1e3,easing:"cubic-bezier(.03, .98, .52, .99)",scale:1,speed:300,disabledAxis:"",reset:!0},Hover=function(e,t){var r=this;if("string"==typeof e&&(e=document.querySelector(e)),!e||1!==e.nodeType)throw new Error("Cannot find target dom to apply hover effects");t=merge({},[defaultConfig,t]),this.target=e,this.config=t,this.layers=[],index(e,function(e){if(1===e.nodeType){var n=e.getAttribute("data-hover-layer");if(n){var i=t.layers[Number(n)].multiple;if(!i)throw new Error("Missing translate config for "+n);r.layers.push(merge({node:e,multiple:void 0===i?.2:i,reverseTranslate:!!t.layers[Number(n)].reverseTranslate},[r.constructor.getInitialTransformMatrix(e)]))}}}),this.target.style.transform="perspective("+this.config.perspective+"px)",this.addEventHandlers()};Hover.getInitialTransformMatrix=function(e){var t=window.getComputedStyle(e).transform.match(/matrix.*\((.*)\)/),r=[1,0,0,1,0,0],n=4,i=5;return t&&t[1]&&(r=t[1].split(/\s*\,\s*/)),16===r.length&&(n=12,i=13),{matrixArr:r,translateXIndex:n,translateYIndex:i}},Hover.prototype.addEventHandlers=function(){this.target.addEventListener("mouseenter",this.onMouseEnter.bind(this)),this.target.addEventListener("mousemove",this.onMouseMove.bind(this)),this.target.addEventListener("mouseleave",this.onMouseLeave.bind(this))},Hover.prototype.doTranslate=function(e,t,r){var n=["webkitTransform","msTransform","mozTransform","transform"],i=e.node,a=e.matrixArr,o=e.translateXIndex,s=e.translateYIndex,l=a.slice();l[o]=Number(l[o])+t,l[s]=Number(l[s])+r;var c=l.join(", ");n.forEach(function(e){i.style[e]=(6===a.length?"matrix":"matrix3d")+"("+c+")"})},Hover.prototype.translateLayers=function(e,t,r){var n=e.multiple,i=e.reverseTranslate,a=Math.floor(n*(.5*document.body.clientWidth+(i?-1:1)*t)),o=Math.floor(n*(.5*document.body.clientHeight+(i?-1:1)*r));this.doTranslate(e,a,o)},Hover.prototype.getValues=function(e){var t=(e.pageX-this.left)/this.width,r=(e.pageY-this.top)/this.height;t=Math.min(Math.max(t,0),1),r=Math.min(Math.max(r,0),1);var n=(this.config.reverseTilt?-1:1)*(this.config.max/2-t*this.config.max).toFixed(2),i=(this.config.reverseTilt?-1:1)*(r*this.config.max-this.config.max/2).toFixed(2);return{tiltX:n,tiltY:i}},Hover.prototype.setTransition=function(){var e=this;clearTimeout(this.transitionTimeout),this.target.style.transition=this.config.speed+"ms "+this.config.easing,this.transitionTimeout=setTimeout(function(t){e.target.style.transition=""},this.config.speed)},Hover.prototype.onMouseEnter=function(e){var t=this;this.width=this.target.offsetWidth,this.height=this.target.offsetHeight,this.left=this.target.offsetLeft,this.top=this.target.offsetTop,this.setTransition(),this.layers.forEach(function(r){r.node.style.transition=t.config.speed+"ms "+t.config.easing,t.translateLayers(r,e.clientX,e.clientY)}),setTimeout(function(){t.layers.forEach(function(e){var t=e.node;t.style.transition="none"})},this.config.speed)},Hover.prototype.onMouseMove=function(e){var t=this,r=this.getValues(e);this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX("+("x"===this.config.disabledAxis?0:r.tiltY)+"deg)\n rotateY("+("y"===this.config.disabledAxis?0:r.tiltX)+"deg)\n scale3d("+this.config.scale+", "+this.config.scale+", "+this.config.scale+")\n ",window.requestAnimationFrame(function(r){t.layers.forEach(function(r){t.translateLayers(r,e.clientX,e.clientY)})})},Hover.prototype.onMouseLeave=function(){var e=this;this.config.reset===!0&&(this.setTransition(),this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX(0deg)\n rotateY(0deg)\n scale3d(1, 1, 1)\n ",this.layers.forEach(function(t){t.node.style.transition=e.config.speed+"ms "+e.config.easing,e.doTranslate(t,0,0)}))};var index$2={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},conversions$1=createCommonjsModule(function(e){function t(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2)}var r=index$2,n={};for(var i in r)r.hasOwnProperty(i)&&(n[r[i]]=i);var a=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var o in a)if(a.hasOwnProperty(o)){if(!("channels"in a[o]))throw new Error("missing channels property: "+o);if(!("labels"in a[o]))throw new Error("missing channel labels property: "+o);if(a[o].labels.length!==a[o].channels)throw new Error("channel and label counts mismatch: "+o);var s=a[o].channels,l=a[o].labels;delete a[o].channels,delete a[o].labels,Object.defineProperty(a[o],"channels",{value:s}),Object.defineProperty(a[o],"labels",{value:l})}a.rgb.hsl=function(e){var t,r,n,i=e[0]/255,a=e[1]/255,o=e[2]/255,s=Math.min(i,a,o),l=Math.max(i,a,o),c=l-s;return l===s?t=0:i===l?t=(a-o)/c:a===l?t=2+(o-i)/c:o===l&&(t=4+(i-a)/c),t=Math.min(60*t,360),t<0&&(t+=360),n=(s+l)/2,r=l===s?0:n<=.5?c/(l+s):c/(2-l-s),[t,100*r,100*n]},a.rgb.hsv=function(e){var t,r,n,i=e[0],a=e[1],o=e[2],s=Math.min(i,a,o),l=Math.max(i,a,o),c=l-s;return r=0===l?0:c/l*1e3/10,l===s?t=0:i===l?t=(a-o)/c:a===l?t=2+(o-i)/c:o===l&&(t=4+(i-a)/c),t=Math.min(60*t,360),t<0&&(t+=360),n=l/255*1e3/10,[t,r,n]},a.rgb.hwb=function(e){var t=e[0],r=e[1],n=e[2],i=a.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(r,n));return n=1-1/255*Math.max(t,Math.max(r,n)),[i,100*o,100*n]},a.rgb.cmyk=function(e){var t,r,n,i,a=e[0]/255,o=e[1]/255,s=e[2]/255;return i=Math.min(1-a,1-o,1-s),t=(1-a-i)/(1-i)||0,r=(1-o-i)/(1-i)||0,n=(1-s-i)/(1-i)||0,[100*t,100*r,100*n,100*i]},a.rgb.keyword=function(e){var i=n[e];if(i)return i;var a,o=1/0;for(var s in r)if(r.hasOwnProperty(s)){var l=r[s],c=t(e,l);c<o&&(o=c,a=s)}return a},a.keyword.rgb=function(e){return r[e]},a.rgb.xyz=function(e){var t=e[0]/255,r=e[1]/255,n=e[2]/255;t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=.4124*t+.3576*r+.1805*n,a=.2126*t+.7152*r+.0722*n,o=.0193*t+.1192*r+.9505*n;return[100*i,100*a,100*o]},a.rgb.lab=function(e){var t,r,n,i=a.rgb.xyz(e),o=i[0],s=i[1],l=i[2];return o/=95.047,s/=100,l/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,t=116*s-16,r=500*(o-s),n=200*(s-l),[t,r,n]},a.hsl.rgb=function(e){var t,r,n,i,a,o=e[0]/360,s=e[1]/100,l=e[2]/100;if(0===s)return a=255*l,[a,a,a];r=l<.5?l*(1+s):l+s-l*s,t=2*l-r,i=[0,0,0];for(var c=0;c<3;c++)n=o+1/3*-(c-1),n<0&&n++,n>1&&n--,a=6*n<1?t+6*(r-t)*n:2*n<1?r:3*n<2?t+(r-t)*(2/3-n)*6:t,i[c]=255*a;return i},a.hsl.hsv=function(e){var t,r,n=e[0],i=e[1]/100,a=e[2]/100,o=i,s=Math.max(a,.01);return a*=2,i*=a<=1?a:2-a,o*=s<=1?s:2-s,r=(a+i)/2,t=0===a?2*o/(s+o):2*i/(a+i),[n,100*t,100*r]},a.hsv.rgb=function(e){var t=e[0]/60,r=e[1]/100,n=e[2]/100,i=Math.floor(t)%6,a=t-Math.floor(t),o=255*n*(1-r),s=255*n*(1-r*a),l=255*n*(1-r*(1-a));switch(n*=255,i){case 0:return[n,l,o];case 1:return[s,n,o];case 2:return[o,n,l];case 3:return[o,s,n];case 4:return[l,o,n];case 5:return[n,o,s]}},a.hsv.hsl=function(e){var t,r,n,i=e[0],a=e[1]/100,o=e[2]/100,s=Math.max(o,.01);return n=(2-a)*o,t=(2-a)*s,r=a*s,r/=t<=1?t:2-t,r=r||0,n/=2,[i,100*r,100*n]},a.hwb.rgb=function(e){var t,r,n,i,a=e[0]/360,o=e[1]/100,s=e[2]/100,l=o+s;l>1&&(o/=l,s/=l),t=Math.floor(6*a),r=1-s,n=6*a-t,0!==(1&t)&&(n=1-n),i=o+n*(r-o);var c,h,u;switch(t){default:case 6:case 0:c=r,h=i,u=o;break;case 1:c=i,h=r,u=o;break;case 2:c=o,h=r,u=i;break;case 3:c=o,h=i,u=r;break;case 4:c=i,h=o,u=r;break;case 5:c=r,h=o,u=i}return[255*c,255*h,255*u]},a.cmyk.rgb=function(e){var t,r,n,i=e[0]/100,a=e[1]/100,o=e[2]/100,s=e[3]/100;return t=1-Math.min(1,i*(1-s)+s),r=1-Math.min(1,a*(1-s)+s),n=1-Math.min(1,o*(1-s)+s),[255*t,255*r,255*n]},a.xyz.rgb=function(e){var t,r,n,i=e[0]/100,a=e[1]/100,o=e[2]/100;return t=3.2406*i+a*-1.5372+o*-.4986,r=i*-.9689+1.8758*a+.0415*o,n=.0557*i+a*-.204+1.057*o,t=t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,t=Math.min(Math.max(0,t),1),r=Math.min(Math.max(0,r),1),n=Math.min(Math.max(0,n),1),[255*t,255*r,255*n]},a.xyz.lab=function(e){var t,r,n,i=e[0],a=e[1],o=e[2];return i/=95.047,a/=100,o/=108.883,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,t=116*a-16,r=500*(i-a),n=200*(a-o),[t,r,n]},a.lab.xyz=function(e){var t,r,n,i=e[0],a=e[1],o=e[2];r=(i+16)/116,t=a/500+r,n=r-o/200;var s=Math.pow(r,3),l=Math.pow(t,3),c=Math.pow(n,3);return r=s>.008856?s:(r-16/116)/7.787,t=l>.008856?l:(t-16/116)/7.787,n=c>.008856?c:(n-16/116)/7.787,t*=95.047,r*=100,n*=108.883,[t,r,n]},a.lab.lch=function(e){var t,r,n,i=e[0],a=e[1],o=e[2];return t=Math.atan2(o,a),r=360*t/2/Math.PI,r<0&&(r+=360),n=Math.sqrt(a*a+o*o),[i,n,r]},a.lch.lab=function(e){var t,r,n,i=e[0],a=e[1],o=e[2];return n=o/360*2*Math.PI,t=a*Math.cos(n),r=a*Math.sin(n),[i,t,r]},a.rgb.ansi16=function(e){var t=e[0],r=e[1],n=e[2],i=1 in arguments?arguments[1]:a.rgb.hsv(e)[2];if(i=Math.round(i/50),0===i)return 30;var o=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(t/255));return 2===i&&(o+=60),o},a.hsv.ansi16=function(e){return a.rgb.ansi16(a.hsv.rgb(e),e[2])},a.rgb.ansi256=function(e){var t=e[0],r=e[1],n=e[2];if(t===r&&r===n)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;var i=16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5);return i},a.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];var r=.5*(~~(e>50)+1),n=(1&t)*r*255,i=(t>>1&1)*r*255,a=(t>>2&1)*r*255;return[n,i,a]},a.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}e-=16;var r,n=Math.floor(e/36)/5*255,i=Math.floor((r=e%36)/6)/5*255,a=r%6/5*255;return[n,i,a]},a.rgb.hex=function(e){var t=((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2])),r=t.toString(16).toUpperCase();return"000000".substring(r.length)+r},a.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var r=t[0];3===t[0].length&&(r=r.split("").map(function(e){return e+e}).join(""));var n=parseInt(r,16),i=n>>16&255,a=n>>8&255,o=255&n;return[i,a,o]},a.rgb.hcg=function(e){var t,r,n=e[0]/255,i=e[1]/255,a=e[2]/255,o=Math.max(Math.max(n,i),a),s=Math.min(Math.min(n,i),a),l=o-s;return t=l<1?s/(1-l):0,r=l<=0?0:o===n?(i-a)/l%6:o===i?2+(a-n)/l:4+(n-i)/l+4,r/=6,r%=1,[360*r,100*l,100*t]},a.hsl.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=1,i=0;return n=r<.5?2*t*r:2*t*(1-r),n<1&&(i=(r-.5*n)/(1-n)),[e[0],100*n,100*i]},a.hsv.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=t*r,i=0;return n<1&&(i=(r-n)/(1-n)),[e[0],100*n,100*i]},a.hcg.rgb=function(e){var t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];var i=[0,0,0],a=t%1*6,o=a%1,s=1-o,l=0;switch(Math.floor(a)){case 0:i[0]=1,i[1]=o,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=o;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=o,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-r)*n,[255*(r*i[0]+l),255*(r*i[1]+l),255*(r*i[2]+l)]},a.hcg.hsv=function(e){var t=e[1]/100,r=e[2]/100,n=t+r*(1-t),i=0;return n>0&&(i=t/n),[e[0],100*i,100*n]},a.hcg.hsl=function(e){var t=e[1]/100,r=e[2]/100,n=r*(1-t)+.5*t,i=0;return n>0&&n<.5?i=t/(2*n):n>=.5&&n<1&&(i=t/(2*(1-n))),[e[0],100*i,100*n]},a.hcg.hwb=function(e){var t=e[1]/100,r=e[2]/100,n=t+r*(1-t);return[e[0],100*(n-t),100*(1-n)]},a.hwb.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=1-r,i=n-t,a=0;return i<1&&(a=(n-i)/(1-i)),[e[0],100*i,100*a]},a.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},a.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},a.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},a.gray.hsl=a.gray.hsv=function(e){return[0,0,e[0]]},a.gray.hwb=function(e){return[0,100,e[0]]},a.gray.cmyk=function(e){return[0,0,0,e[0]]},a.gray.lab=function(e){return[e[0],0,0]},a.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),r=(t<<16)+(t<<8)+t,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n},a.rgb.gray=function(e){var t=(e[0]+e[1]+e[2])/3;return[t/255*100]}}),conversions$3=conversions$1,models$1=Object.keys(conversions$3),route$1=function(e){for(var t=deriveBFS(e),r={},n=Object.keys(t),i=n.length,a=0;a<i;a++){var o=n[a],s=t[o];null!==s.parent&&(r[o]=wrapConversion(o,t))}return r},conversions=conversions$1,route=route$1,convert={},models=Object.keys(conversions);models.forEach(function(e){convert[e]={},Object.defineProperty(convert[e],"channels",{value:conversions[e].channels}),Object.defineProperty(convert[e],"labels",{value:conversions[e].labels});var t=route(e),r=Object.keys(t);r.forEach(function(r){var n=t[r];convert[e][r]=wrapRounded(n),convert[e][r].raw=wrapRaw(n)})});var index$1=convert,throttle=function(e,t,r,n){function i(){function i(){o=Number(new Date),r.apply(l,h)}function s(){a=void 0}var l=this,c=Number(new Date)-o,h=arguments;n&&!a&&i(),a&&clearTimeout(a),void 0===n&&c>e?i():t!==!0&&(a=setTimeout(n?s:i,void 0===n?e-c:e))}var a,o=0;return"boolean"!=typeof t&&(n=r,r=t,t=void 0),i},defaultConfig$1={stageSwitchTransition:800,stageSwitchDelay:0,stageSwitchEasing:"cubic-bezier(.86, 0, .07, 1)",disableAfterSwitching:500,stages:[]},defaultStageConfig={scrollNumber:1,transition:200,easing:"ease",items:[]},numberRegExp=new RegExp(/-?\d+(?:\.\d+)?/,"g"),vendors=["webkit","ms","moz",""],Scroll=function(e,t){if("string"==typeof e&&(e=document.querySelector(e)),!e||1!==e.nodeType)throw new Error("Cannot find target dom to apply scroll effects");t=merge({},[defaultConfig$1,t]),e.style.overflow="hidden",this.target=e,this.config=t,this.animating=!1,this.switching=!1,this.stages=[],this.activeStageIndex=0,this.initStages(),this.processStages(),this.defineActiveStage(),this.addEventListeners()};Scroll.prototype.defineActiveStage=function(){var e=this.stages[this.activeStageIndex],t=this;Object.defineProperty(this,"activeStage",{get:function(){return e},set:function(r){if(r!==e){var n=JSON.parse(JSON.stringify(e));e=r,t.activeStageIndex=t.stages.findIndex(function(e){return e===r}),t.handleActiveStageChange(),t.target.dispatchEvent(new CustomEvent("stage-change",{detail:{previous:{id:n.id,node:n.node,config:n.stageConfig,step:n.step},current:{id:r.id,node:r.node,config:r.stageConfig}}}))}}})},Scroll.prototype.addEventListeners=function(){this.boundHandleScroll=this.handleScroll.bind(this),this.throttledHandleStepChange=throttle(50,!0,this.handleStepChange,!0),document.addEventListener("wheel",this.boundHandleScroll)},Scroll.prototype.removeEventListeners=function(){document.removeEventListener("wheel",this.boundHandleScroll)},Scroll.prototype.initStages=function(){var e=this;index(this.target,function(t){if(1===t.nodeType){var r=t.getAttribute("data-scroll-stage-id");if(r){var n=getObjectFromArrById(e.config.stages,r);if(!n)throw new Error("\n Missing scrolling config for stage id: "+r+"\n ");t.style.transition="\n "+e.config.stageSwitchTransition+"ms "+e.config.stageSwitchEasing+" "+e.config.stageSwitchDelay+"ms\n ",e.stages.push({node:t,stageConfig:merge({},[defaultStageConfig,n]),id:r,step:0})}}})},Scroll.prototype.processStages=function(){var e=this;this.stages.forEach(function(t){e.constructor.attachNodeToItems(t),e.processItemEffects(t)})},Scroll.attachNodeToItems=function(e){index(e.node,function(t){if(1===t.nodeType){var r=t.getAttribute("data-scroll-item-id");if(r){var n=getObjectFromArrById(e.stageConfig.items,r);if(!n)throw new Error("Missing scrolling config for item id: "+r);n.node=t}}})},Scroll.prototype.processItemEffects=function(e){var t=this;e.stageConfig.items.forEach(function(r){r.effects.forEach(function(r){void 0===r.startAt&&(r.startAt=0),void 0===r.endAt&&(r.endAt=Number(e.stageConfig.scrollNumber)),t.constructor.processColorValues(r),r.startNumbers=(r.start.match(numberRegExp)||[]).map(function(e){return Number(e)}),r.endNumbers=(r.end.match(numberRegExp)||[]).map(function(e){return Number(e)}),r.strings=r.start.split(numberRegExp)})})},Scroll.getCurrentStyleValue=function(e,t){var r=e.startAt,n=e.endAt,i=e.startNumbers,a=e.endNumbers,o=e.strings,s=e.isColor;t=Math.min(n,Math.max(r,t));var l=o[0],c=-1;return i&&i.length>0&&i.forEach(function(e,i){/rgba/.test(o[i])&&(c=i+3);var h=e+(t-r)*(a[i]-e)/(n-r);s&&i!==c&&(h=Math.round(h)),l+=""+h+o[i+1]}),l},Scroll.processColorValues=function(e){["start","end"].forEach(function(t){var r=e[t],n=is(r);if(n){if(e.isColor=!0,"hex"===n)r="\n rgb("+index$1.hex.rgb(r).join(",")+")\n ";else if("hsl"===n){var i=r.match(/hsla?\((.*)\)/)[1].split(/\s*,\s*/).map(function(e){return parseFloat(e)}),a=i[0],o=i[1],s=i[2],l=i[3];r="\n rgba("+index$1.hsl.rgb([a,o,s]).join(",")+", "+(void 0===l?1:l)+")\n "}e[t]=r}})},Scroll.prototype.setActiveStage=function(e,t){if(void 0===t&&(t=!1),this.activeStage.id!==e){var r=this.activeStageIndex;this.activeStage.step=0;var n=getObjectFromArrById(this.stages,e)||this.stages[0],i=this.stages.findIndex(function(e){return e===n});t?(n.step=r<i?0:Number(n.stageConfig.scrollNumber),this.activeStage=n,this.handleStepChange(!1,!1)):(this.activeStage=n,this.handleStepChange(!1,!1))}},Scroll.prototype.handleActiveStageChange=function(){var e=this;clearTimeout(this.switchingTimeout),this.switching=!0,this.stages.forEach(function(t){vendors.forEach(function(r){var n=r.length?r+"Transform":"transform";t.node.style[n]="translateY("+100*-e.activeStageIndex+"%)"})}),this.switchingTimeout=setTimeout(function(t){e.switching=!1},Number(this.config.stageSwitchTransition)+Number(this.config.disableAfterSwitching))},Scroll.prototype.setStep=function(e){var t=typeof e;if("number"!==t)throw new Error("step should be a number, got "+t);if(e<0||e>Number(this.activeStage.stageConfig.scrollNumber))throw new Error("\n step should be within [0, "+this.activeStage.stageConfig.scrollNumber+"], got "+e+"\n ");this.activeStage.step!==e&&(this.activeStage.step=e,this.handleStepChange())},Scroll.prototype.getActiveStage=function(){return this.activeStage},Scroll.prototype.getStep=function(){return this.activeStage.step},Scroll.prototype.handleStepChange=function(e,t){var r=this;void 0===e&&(e=!0),void 0===t&&(t=!0);var n=this.activeStage.step,i=this.activeStage.stageConfig,a=this.activeStageIndex;if(n>Number(i.scrollNumber)){if(a===this.stages.length-1)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"bottom"}})),void(this.activeStage.step=Number(i.scrollNumber));this.setActiveStage(this.stages[a+1].id,!0)}else if(n<0){if(0===a)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"top"}})),void(this.activeStage.step=0);this.setActiveStage(this.stages[a-1].id,!0)}else clearTimeout(this.animatingTimeout),this.animating=!0,i.items.forEach(function(t){t.node.style.transition=e?i.transition+"ms "+i.easing:"none",t.effects.forEach(function(e){t.node.style[e.property]=r.constructor.getCurrentStyleValue(e,n)})}),t&&this.target.dispatchEvent(new CustomEvent("step-change",{detail:{activeStage:{id:this.activeStage.id,node:this.activeStage.node,config:i},current:n}})),this.animatingTimeout=setTimeout(function(e){r.animating=!1},e?Number(i.transition):0)},Scroll.prototype.handleScroll=function(e){e.preventDefault(),this.animating||this.switching||(this.activeStage.step+=e.deltaY>0?1:-1,this.throttledHandleStepChange())},Scroll.prototype.destroy=function(){this.removeEventListeners()},Scroll.prototype.restore=function(){this.addEventListeners()},exports.Hover=Hover,exports.Scroll=Scroll; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.perspective=t.perspective||{})}(this,function(t){"use strict";function e(t,e){"length"in t||(t=[t]),t=c.call(t);for(;t.length;){var n=t.shift(),r=e(n);if(r)return r;n.childNodes&&n.childNodes.length&&(t=c.call(n.childNodes).concat(t))}}function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(){for(var t={},e=y.length,n=0;n<e;n++)t[y[n]]={distance:-1,parent:null};return t}function a(t){var e=r(),n=[t];for(e[t].distance=0;n.length;)for(var a=n.pop(),i=Object.keys(b[a]),s=i.length,o=0;o<s;o++){var h=i[o],c=e[h];c.distance===-1&&(c.distance=e[a].distance+1,c.parent=a,n.unshift(h))}return e}function i(t,e){return function(n){return e(t(n))}}function s(t,e){for(var n=[e[t].parent,t],r=b[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=i(b[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}function o(t){var e=function(e){return void 0===e||null===e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}function h(t){var e=function(e){if(void 0===e||null===e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}var c=Array.prototype.slice,l=e,u=function(t,e){for(var n,r=0,a=t.length;r<a;r++){var i=t[r];if(i.id===e){n=i;break}}if(n)return n;throw new Error("Cannot find "+e+" id in "+JSON.stringify(t))},g=function(t){var e={hsl:new RegExp(/^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*[\d\.]+)?\s*\)$/),hex:new RegExp(/^#[a-f0-9]{3}([a-f0-9]{3})?$/,"i")};for(var n in e)if(e.hasOwnProperty(n)&&e[n].test(t))return n},f=function(t,e){for(var n=0,r=e.length;n<r;n++){var a=e[n]||{};for(var i in a)if(a.hasOwnProperty(i)){var s=a[i];void 0!==s&&(t[i]=s)}}return t},d={layers:[],max:20,reverse:!1,perspective:1e3,easing:"cubic-bezier(.03, .98, .52, .99)",scale:"1",speed:"300",disabledAxis:null,reset:!0},v=function(t,e){var n=this;if("string"==typeof t&&(t=document.querySelector(t)),!t||1!==t.nodeType)throw new Error("Cannot find target dom to apply hover effects");e=f({},[d,e]),this.target=t,this.config=e,this.layers=[],l(t,function(t){if(1===t.nodeType){var r=t.getAttribute("data-hover-layer");if(r){var a=e.layers[Number(r)].speed;if(!a)throw new Error("Missing translate config for "+r);n.layers.push(f({node:t,speed:void 0===a?.2:a,reverse:!!e.layers[Number(r)].reverse},[n.constructor.getInitialTransformMatrix(t)]))}}}),this.target.style.transform="perspective("+this.config.perspective+"px)",this.addEventHandlers()};v.getInitialTransformMatrix=function(t){var e=window.getComputedStyle(t).transform.match(/matrix.*\((.*)\)/),n=[1,0,0,1,0,0],r=4,a=5;return e&&e[1]&&(n=e[1].split(/\s*\,\s*/)),16===n.length&&(r=12,a=13),{matrixArr:n,translateXIndex:r,translateYIndex:a}},v.prototype.addEventHandlers=function(){this.target.addEventListener("mouseenter",this.onMouseEnter.bind(this)),this.target.addEventListener("mousemove",this.onMouseMove.bind(this)),this.target.addEventListener("mouseleave",this.onMouseLeave.bind(this))},v.prototype.doTranslate=function(t,e,n){var r=["webkitTransform","msTransform","mozTransform","transform"],a=t.node,i=t.matrixArr,s=t.translateXIndex,o=t.translateYIndex,h=i.slice();h[s]=Number(h[s])+e,h[o]=Number(h[o])+n;var c=h.join(", ");r.forEach(function(t){a.style[t]=(6===i.length?"matrix":"matrix3d")+"("+c+")"})},v.prototype.translateLayers=function(t,e,n){var r=t.speed,a=t.reverse,i=Math.floor(r*(.5*document.body.clientWidth+(a?-1:1)*e)),s=Math.floor(r*(.5*document.body.clientHeight+(a?-1:1)*n));this.doTranslate(t,i,s)},v.prototype.getValues=function(t){var e=(t.pageX-this.left)/this.width,n=(t.pageY-this.top)/this.height;e=Math.min(Math.max(e,0),1),n=Math.min(Math.max(n,0),1);var r=(this.config.reverse?-1:1)*(this.config.max/2-e*this.config.max).toFixed(2),a=(this.config.reverse?-1:1)*(n*this.config.max-this.config.max/2).toFixed(2);return{tiltX:r,tiltY:a}},v.prototype.setTransition=function(){var t=this;clearTimeout(this.transitionTimeout),this.target.style.transition=this.config.speed+"ms "+this.config.easing,this.transitionTimeout=setTimeout(function(e){t.target.style.transition=""},this.config.speed)},v.prototype.onMouseEnter=function(t){var e=this;this.width=this.target.offsetWidth,this.height=this.target.offsetHeight,this.left=this.target.offsetLeft,this.top=this.target.offsetTop,this.setTransition(),this.layers.forEach(function(n){n.node.style.transition=e.config.speed+"ms "+e.config.easing,e.translateLayers(n,t.clientX,t.clientY)}),setTimeout(function(){e.layers.forEach(function(t){var e=t.node;e.style.transition="none"})},this.config.speed)},v.prototype.onMouseMove=function(t){var e=this,n=this.getValues(t);this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX("+("x"===this.config.disabledAxis?0:n.tiltY)+"deg)\n rotateY("+("y"===this.config.disabledAxis?0:n.tiltX)+"deg)\n scale3d("+this.config.scale+", "+this.config.scale+", "+this.config.scale+")\n ",window.requestAnimationFrame(function(n){e.layers.forEach(function(n){e.translateLayers(n,t.clientX,t.clientY)})})},v.prototype.onMouseLeave=function(){var t=this;this.config.reset===!0&&(this.setTransition(),this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX(0deg)\n rotateY(0deg)\n scale3d(1, 1, 1)\n ",this.layers.forEach(function(e){e.node.style.transition=t.config.speed+"ms "+t.config.easing,t.doTranslate(e,0,0)}))};var p={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},m=n(function(t){function e(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}var n=p,r={};for(var a in n)n.hasOwnProperty(a)&&(r[n[a]]=a);var i=t.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var s in i)if(i.hasOwnProperty(s)){if(!("channels"in i[s]))throw new Error("missing channels property: "+s);if(!("labels"in i[s]))throw new Error("missing channel labels property: "+s);if(i[s].labels.length!==i[s].channels)throw new Error("channel and label counts mismatch: "+s);var o=i[s].channels,h=i[s].labels;delete i[s].channels,delete i[s].labels,Object.defineProperty(i[s],"channels",{value:o}),Object.defineProperty(i[s],"labels",{value:h})}i.rgb.hsl=function(t){var e,n,r,a=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(a,i,s),h=Math.max(a,i,s),c=h-o;return h===o?e=0:a===h?e=(i-s)/c:i===h?e=2+(s-a)/c:s===h&&(e=4+(a-i)/c),e=Math.min(60*e,360),e<0&&(e+=360),r=(o+h)/2,n=h===o?0:r<=.5?c/(h+o):c/(2-h-o),[e,100*n,100*r]},i.rgb.hsv=function(t){var e,n,r,a=t[0],i=t[1],s=t[2],o=Math.min(a,i,s),h=Math.max(a,i,s),c=h-o;return n=0===h?0:c/h*1e3/10,h===o?e=0:a===h?e=(i-s)/c:i===h?e=2+(s-a)/c:s===h&&(e=4+(a-i)/c),e=Math.min(60*e,360),e<0&&(e+=360),r=h/255*1e3/10,[e,n,r]},i.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2],a=i.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[a,100*s,100*r]},i.rgb.cmyk=function(t){var e,n,r,a,i=t[0]/255,s=t[1]/255,o=t[2]/255;return a=Math.min(1-i,1-s,1-o),e=(1-i-a)/(1-a)||0,n=(1-s-a)/(1-a)||0,r=(1-o-a)/(1-a)||0,[100*e,100*n,100*r,100*a]},i.rgb.keyword=function(t){var a=r[t];if(a)return a;var i,s=1/0;for(var o in n)if(n.hasOwnProperty(o)){var h=n[o],c=e(t,h);c<s&&(s=c,i=o)}return i},i.keyword.rgb=function(t){return n[t]},i.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;var a=.4124*e+.3576*n+.1805*r,i=.2126*e+.7152*n+.0722*r,s=.0193*e+.1192*n+.9505*r;return[100*a,100*i,100*s]},i.rgb.lab=function(t){var e,n,r,a=i.rgb.xyz(t),s=a[0],o=a[1],h=a[2];return s/=95.047,o/=100,h/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,e=116*o-16,n=500*(s-o),r=200*(o-h),[e,n,r]},i.hsl.rgb=function(t){var e,n,r,a,i,s=t[0]/360,o=t[1]/100,h=t[2]/100;if(0===o)return i=255*h,[i,i,i];n=h<.5?h*(1+o):h+o-h*o,e=2*h-n,a=[0,0,0];for(var c=0;c<3;c++)r=s+1/3*-(c-1),r<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[c]=255*i;return a},i.hsl.hsv=function(t){var e,n,r=t[0],a=t[1]/100,i=t[2]/100,s=a,o=Math.max(i,.01);return i*=2,a*=i<=1?i:2-i,s*=o<=1?o:2-o,n=(i+a)/2,e=0===i?2*s/(o+s):2*a/(i+a),[r,100*e,100*n]},i.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,i=e-Math.floor(e),s=255*r*(1-n),o=255*r*(1-n*i),h=255*r*(1-n*(1-i));switch(r*=255,a){case 0:return[r,h,s];case 1:return[o,r,s];case 2:return[s,r,h];case 3:return[s,o,r];case 4:return[h,s,r];case 5:return[r,s,o]}},i.hsv.hsl=function(t){var e,n,r,a=t[0],i=t[1]/100,s=t[2]/100,o=Math.max(s,.01);return r=(2-i)*s,e=(2-i)*o,n=i*o,n/=e<=1?e:2-e,n=n||0,r/=2,[a,100*n,100*r]},i.hwb.rgb=function(t){var e,n,r,a,i=t[0]/360,s=t[1]/100,o=t[2]/100,h=s+o;h>1&&(s/=h,o/=h),e=Math.floor(6*i),n=1-o,r=6*i-e,0!==(1&e)&&(r=1-r),a=s+r*(n-s);var c,l,u;switch(e){default:case 6:case 0:c=n,l=a,u=s;break;case 1:c=a,l=n,u=s;break;case 2:c=s,l=n,u=a;break;case 3:c=s,l=a,u=n;break;case 4:c=a,l=s,u=n;break;case 5:c=n,l=s,u=a}return[255*c,255*l,255*u]},i.cmyk.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,s=t[2]/100,o=t[3]/100;return e=1-Math.min(1,a*(1-o)+o),n=1-Math.min(1,i*(1-o)+o),r=1-Math.min(1,s*(1-o)+o),[255*e,255*n,255*r]},i.xyz.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,s=t[2]/100;return e=3.2406*a+i*-1.5372+s*-.4986,n=a*-.9689+1.8758*i+.0415*s,r=.0557*a+i*-.204+1.057*s,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,e=Math.min(Math.max(0,e),1),n=Math.min(Math.max(0,n),1),r=Math.min(Math.max(0,r),1),[255*e,255*n,255*r]},i.xyz.lab=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return a/=95.047,i/=100,s/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,e=116*i-16,n=500*(a-i),r=200*(i-s),[e,n,r]},i.lab.xyz=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];n=(a+16)/116,e=i/500+n,r=n-s/200;var o=Math.pow(n,3),h=Math.pow(e,3),c=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=h>.008856?h:(e-16/116)/7.787,r=c>.008856?c:(r-16/116)/7.787,e*=95.047,n*=100,r*=108.883,[e,n,r]},i.lab.lch=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return e=Math.atan2(s,i),n=360*e/2/Math.PI,n<0&&(n+=360),r=Math.sqrt(i*i+s*s),[a,r,n]},i.lch.lab=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return r=s/360*2*Math.PI,e=i*Math.cos(r),n=i*Math.sin(r),[a,e,n]},i.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:i.rgb.hsv(t)[2];if(a=Math.round(a/50),0===a)return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(s+=60),s},i.hsv.ansi16=function(t){return i.rgb.ansi16(i.hsv.rgb(t),t[2])},i.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];if(e===n&&n===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var a=16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5);return a},i.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var n=.5*(~~(t>50)+1),r=(1&e)*n*255,a=(e>>1&1)*n*255,i=(e>>2&1)*n*255;return[r,a,i]},i.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}t-=16;var n,r=Math.floor(t/36)/5*255,a=Math.floor((n=t%36)/6)/5*255,i=n%6/5*255;return[r,a,i]},i.rgb.hex=function(t){var e=((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2])),n=e.toString(16).toUpperCase();return"000000".substring(n.length)+n},i.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map(function(t){return t+t}).join(""));var r=parseInt(n,16),a=r>>16&255,i=r>>8&255,s=255&r;return[a,i,s]},i.rgb.hcg=function(t){var e,n,r=t[0]/255,a=t[1]/255,i=t[2]/255,s=Math.max(Math.max(r,a),i),o=Math.min(Math.min(r,a),i),h=s-o;return e=h<1?o/(1-h):0,n=h<=0?0:s===r?(a-i)/h%6:s===a?2+(i-r)/h:4+(r-a)/h+4,n/=6,n%=1,[360*n,100*h,100*e]},i.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return r=n<.5?2*e*n:2*e*(1-n),r<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},i.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},i.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a=[0,0,0],i=e%1*6,s=i%1,o=1-s,h=0;switch(Math.floor(i)){case 0:a[0]=1,a[1]=s,a[2]=0;break;case 1:a[0]=o,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=s;break;case 3:a[0]=0,a[1]=o,a[2]=1;break;case 4:a[0]=s,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=o}return h=(1-n)*r,[255*(n*a[0]+h),255*(n*a[1]+h),255*(n*a[2]+h)]},i.hcg.hsv=function(t){var e=t[1]/100,n=t[2]/100,r=e+n*(1-e),a=0;return r>0&&(a=e/r),[t[0],100*a,100*r]},i.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100,r=n*(1-e)+.5*e,a=0;return r>0&&r<.5?a=e/(2*r):r>=.5&&r<1&&(a=e/(2*(1-r))),[t[0],100*a,100*r]},i.hcg.hwb=function(t){var e=t[1]/100,n=t[2]/100,r=e+n*(1-e);return[t[0],100*(r-e),100*(1-r)]},i.hwb.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1-n,a=r-e,i=0;return a<1&&(i=(r-a)/(1-a)),[t[0],100*a,100*i]},i.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},i.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},i.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},i.gray.hsl=i.gray.hsv=function(t){return[0,0,t[0]]},i.gray.hwb=function(t){return[0,100,t[0]]},i.gray.cmyk=function(t){return[0,0,0,t[0]]},i.gray.lab=function(t){return[t[0],0,0]},i.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=(e<<16)+(e<<8)+e,r=n.toString(16).toUpperCase();return"000000".substring(r.length)+r},i.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]}}),b=m,y=Object.keys(b),w=function(t){for(var e=a(t),n={},r=Object.keys(e),i=r.length,o=0;o<i;o++){var h=r[o],c=e[h];null!==c.parent&&(n[h]=s(h,e))}return n},M=m,x=w,S={},k=Object.keys(M);k.forEach(function(t){S[t]={},Object.defineProperty(S[t],"channels",{value:M[t].channels}),Object.defineProperty(S[t],"labels",{value:M[t].labels});var e=x(t),n=Object.keys(e);n.forEach(function(n){var r=e[n];S[t][n]=h(r),S[t][n].raw=o(r)})});var E=S,T=function(t,e,n,r){function a(){function a(){s=Number(new Date),n.apply(h,l)}function o(){i=void 0}var h=this,c=Number(new Date)-s,l=arguments;r&&!i&&a(),i&&clearTimeout(i),void 0===r&&c>t?a():e!==!0&&(i=setTimeout(r?o:a,void 0===r?t-c:t))}var i,s=0;return"boolean"!=typeof e&&(r=n,n=e,e=void 0),a},C={stageSwitchTransition:800,stageSwitchDelay:0,stageSwitchEasing:"cubic-bezier(.86, 0, .07, 1)",disableAfterSwitching:500,stages:[]},N={scrollNumber:1,transition:200,easing:"ease",items:[]},A=new RegExp(/-?\d+(?:\.\d+)?/,"g"),I=["webkit","ms","moz",""],O=function(t,e){if("string"==typeof t&&(t=document.querySelector(t)),!t||1!==t.nodeType)throw new Error("Cannot find target dom to apply scroll effects");e=f({},[C,e]),t.style.overflow="hidden",this.target=t,this.config=e,this.animating=!1,this.switching=!1,this.stages=[],this.activeStageIndex=0,this.initStages(),this.processStages(),this.defineActiveStage(),this.addEventListeners()};O.prototype.defineActiveStage=function(){var t=this.stages[this.activeStageIndex],e=this;Object.defineProperty(this,"activeStage",{get:function(){return t},set:function(n){if(n!==t){var r=JSON.parse(JSON.stringify(t));t=n,e.activeStageIndex=e.stages.findIndex(function(t){return t===n}),e.handleActiveStageChange(),e.target.dispatchEvent(new CustomEvent("stage-change",{detail:{previous:{id:r.id,node:r.node,config:r.stageConfig,step:r.step},current:{id:n.id,node:n.node,config:n.stageConfig}}}))}}})},O.prototype.addEventListeners=function(){this.boundHandleScroll=this.handleScroll.bind(this),this.throttledHandleStepChange=T(50,!0,this.handleStepChange,!0),document.addEventListener("wheel",this.boundHandleScroll)},O.prototype.removeEventListeners=function(){document.removeEventListener("wheel",this.boundHandleScroll)},O.prototype.initStages=function(){var t=this;l(this.target,function(e){if(1===e.nodeType){var n=e.getAttribute("data-scroll-stage-id");if(n){var r=u(t.config.stages,n);if(!r)throw new Error("\n Missing scrolling config for stage id: "+n+"\n ");e.style.transition="\n "+t.config.stageSwitchTransition+"ms "+t.config.stageSwitchEasing+" "+t.config.stageSwitchDelay+"ms\n ",t.stages.push({node:e,stageConfig:f({},[N,r]),id:n,step:0})}}})},O.prototype.processStages=function(){var t=this;this.stages.forEach(function(e){t.constructor.attachNodeToItems(e),t.processItemEffects(e)})},O.attachNodeToItems=function(t){l(t.node,function(e){if(1===e.nodeType){var n=e.getAttribute("data-scroll-item-id");if(n){var r=u(t.stageConfig.items,n);if(!r)throw new Error("Missing scrolling config for item id: "+n);r.node=e}}})},O.prototype.processItemEffects=function(t){var e=this;t.stageConfig.items.forEach(function(n){n.effects.forEach(function(n){void 0===n.startAt&&(n.startAt=0),void 0===n.endAt&&(n.endAt=Number(t.stageConfig.scrollNumber)),e.constructor.processColorValues(n),n.startNumbers=(n.start.match(A)||[]).map(function(t){return Number(t)}),n.endNumbers=(n.end.match(A)||[]).map(function(t){return Number(t)}),n.strings=n.start.split(A)})})},O.getCurrentStyleValue=function(t,e){var n=t.startAt,r=t.endAt,a=t.startNumbers,i=t.endNumbers,s=t.strings,o=t.isColor;e=Math.min(r,Math.max(n,e));var h=s[0],c=-1;return a&&a.length>0&&a.forEach(function(t,a){/rgba/.test(s[a])&&(c=a+3);var l=t+(e-n)*(i[a]-t)/(r-n);o&&a!==c&&(l=Math.round(l)),h+=""+l+s[a+1]}),h},O.processColorValues=function(t){["start","end"].forEach(function(e){var n=t[e],r=g(n);if(r){if(t.isColor=!0,"hex"===r)n="\n rgb("+E.hex.rgb(n).join(",")+")\n ";else if("hsl"===r){var a=n.match(/hsla?\((.*)\)/)[1].split(/\s*,\s*/).map(function(t){return parseFloat(t)}),i=a[0],s=a[1],o=a[2],h=a[3];n="\n rgba("+E.hsl.rgb([i,s,o]).join(",")+", "+(void 0===h?1:h)+")\n "}t[e]=n}})},O.prototype.setActiveStage=function(t,e){if(void 0===e&&(e=!1),this.activeStage.id!==t){var n=this.activeStageIndex;this.activeStage.step=0;var r=u(this.stages,t)||this.stages[0],a=this.stages.findIndex(function(t){return t===r});e?(r.step=n<a?0:Number(r.stageConfig.scrollNumber),this.activeStage=r,this.handleStepChange(!1,!1)):(this.activeStage=r,this.handleStepChange(!1,!1))}},O.prototype.handleActiveStageChange=function(){var t=this;clearTimeout(this.switchingTimeout),this.switching=!0,this.stages.forEach(function(e){I.forEach(function(n){var r=n.length?n+"Transform":"transform";e.node.style[r]="translateY("+100*-t.activeStageIndex+"%)"})}),this.switchingTimeout=setTimeout(function(e){t.switching=!1},Number(this.config.stageSwitchTransition)+Number(this.config.disableAfterSwitching))},O.prototype.setStep=function(t){var e=typeof t;if("number"!==e)throw new Error("step should be not a number, got "+e);if(t<0||t>Number(this.activeStage.stageConfig.scrollNumber))throw new Error("\n step should be within [0, "+this.activeStage.stageConfig.scrollNumber+"], got "+t+"\n ");this.activeStage.step!==t&&(this.activeStage.step=t,this.handleStepChange())},O.prototype.getActiveStage=function(){return this.activeStage},O.prototype.getStep=function(){return this.activeStage.step},O.prototype.handleStepChange=function(t,e){var n=this;void 0===t&&(t=!0),void 0===e&&(e=!0);var r=this.activeStage.step,a=this.activeStage.stageConfig,i=this.activeStageIndex;if(r>Number(a.scrollNumber)){if(i===this.stages.length-1)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"bottom"}})),void(this.activeStage.step=Number(a.scrollNumber));this.setActiveStage(this.stages[i+1].id,!0)}else if(r<0){if(0===i)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"top"}})),void(this.activeStage.step=0);this.setActiveStage(this.stages[i-1].id,!0)}else clearTimeout(this.animatingTimeout),this.animating=!0,a.items.forEach(function(e){e.node.style.transition=t?a.transition+"ms "+a.easing:"none",e.effects.forEach(function(t){e.node.style[t.property]=n.constructor.getCurrentStyleValue(t,r)})}),e&&this.target.dispatchEvent(new CustomEvent("step-change",{detail:{activeStage:{id:this.activeStage.id,node:this.activeStage.node,config:a},current:r}})),this.animatingTimeout=setTimeout(function(t){n.animating=!1},t?Number(a.transition):0)},O.prototype.handleScroll=function(t){t.preventDefault(),this.animating||this.switching||(this.activeStage.step+=t.deltaY>0?1:-1,this.throttledHandleStepChange())},t.Hover=v,t.Scroll=O,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.perspective=t.perspective||{})}(this,function(t){"use strict";function e(t,e){"length"in t||(t=[t]),t=c.call(t);for(;t.length;){var n=t.shift(),r=e(n);if(r)return r;n.childNodes&&n.childNodes.length&&(t=c.call(n.childNodes).concat(t))}}function n(t,e){return e={exports:{}},t(e,e.exports),e.exports}function r(){for(var t={},e=y.length,n=0;n<e;n++)t[y[n]]={distance:-1,parent:null};return t}function a(t){var e=r(),n=[t];for(e[t].distance=0;n.length;)for(var a=n.pop(),i=Object.keys(b[a]),s=i.length,o=0;o<s;o++){var h=i[o],c=e[h];c.distance===-1&&(c.distance=e[a].distance+1,c.parent=a,n.unshift(h))}return e}function i(t,e){return function(n){return e(t(n))}}function s(t,e){for(var n=[e[t].parent,t],r=b[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=i(b[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}function o(t){var e=function(e){return void 0===e||null===e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}function h(t){var e=function(e){if(void 0===e||null===e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}var c=Array.prototype.slice,l=e,u=function(t,e){for(var n,r=0,a=t.length;r<a;r++){var i=t[r];if(i.id===e){n=i;break}}if(n)return n;throw new Error("Cannot find "+e+" id in "+JSON.stringify(t))},g=function(t){var e={hsl:new RegExp(/^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*[\d\.]+)?\s*\)$/),hex:new RegExp(/^#[a-f0-9]{3}([a-f0-9]{3})?$/,"i")};for(var n in e)if(e.hasOwnProperty(n)&&e[n].test(t))return n},f=function(t,e){for(var n=0,r=e.length;n<r;n++){var a=e[n]||{};for(var i in a)if(a.hasOwnProperty(i)){var s=a[i];void 0!==s&&(t[i]=s)}}return t},d={layers:[],max:20,reverseTilt:!1,perspective:1e3,easing:"cubic-bezier(.03, .98, .52, .99)",scale:1,speed:300,disabledAxis:"",reset:!0},v=function(t,e){var n=this;if("string"==typeof t&&(t=document.querySelector(t)),!t||1!==t.nodeType)throw new Error("Cannot find target dom to apply hover effects");e=f({},[d,e]),this.target=t,this.config=e,this.layers=[],l(t,function(t){if(1===t.nodeType){var r=t.getAttribute("data-hover-layer");if(r){var a=e.layers[Number(r)].multiple;if(!a)throw new Error("Missing translate config for "+r);n.layers.push(f({node:t,multiple:void 0===a?.2:a,reverseTranslate:!!e.layers[Number(r)].reverseTranslate},[n.constructor.getInitialTransformMatrix(t)]))}}}),this.target.style.transform="perspective("+this.config.perspective+"px)",this.addEventHandlers()};v.getInitialTransformMatrix=function(t){var e=window.getComputedStyle(t).transform.match(/matrix.*\((.*)\)/),n=[1,0,0,1,0,0],r=4,a=5;return e&&e[1]&&(n=e[1].split(/\s*\,\s*/)),16===n.length&&(r=12,a=13),{matrixArr:n,translateXIndex:r,translateYIndex:a}},v.prototype.addEventHandlers=function(){this.target.addEventListener("mouseenter",this.onMouseEnter.bind(this)),this.target.addEventListener("mousemove",this.onMouseMove.bind(this)),this.target.addEventListener("mouseleave",this.onMouseLeave.bind(this))},v.prototype.doTranslate=function(t,e,n){var r=["webkitTransform","msTransform","mozTransform","transform"],a=t.node,i=t.matrixArr,s=t.translateXIndex,o=t.translateYIndex,h=i.slice();h[s]=Number(h[s])+e,h[o]=Number(h[o])+n;var c=h.join(", ");r.forEach(function(t){a.style[t]=(6===i.length?"matrix":"matrix3d")+"("+c+")"})},v.prototype.translateLayers=function(t,e,n){var r=t.multiple,a=t.reverseTranslate,i=Math.floor(r*(.5*document.body.clientWidth+(a?-1:1)*e)),s=Math.floor(r*(.5*document.body.clientHeight+(a?-1:1)*n));this.doTranslate(t,i,s)},v.prototype.getValues=function(t){var e=(t.pageX-this.left)/this.width,n=(t.pageY-this.top)/this.height;e=Math.min(Math.max(e,0),1),n=Math.min(Math.max(n,0),1);var r=(this.config.reverseTilt?-1:1)*(this.config.max/2-e*this.config.max).toFixed(2),a=(this.config.reverseTilt?-1:1)*(n*this.config.max-this.config.max/2).toFixed(2);return{tiltX:r,tiltY:a}},v.prototype.setTransition=function(){var t=this;clearTimeout(this.transitionTimeout),this.target.style.transition=this.config.speed+"ms "+this.config.easing,this.transitionTimeout=setTimeout(function(e){t.target.style.transition=""},this.config.speed)},v.prototype.onMouseEnter=function(t){var e=this;this.width=this.target.offsetWidth,this.height=this.target.offsetHeight,this.left=this.target.offsetLeft,this.top=this.target.offsetTop,this.setTransition(),this.layers.forEach(function(n){n.node.style.transition=e.config.speed+"ms "+e.config.easing,e.translateLayers(n,t.clientX,t.clientY)}),setTimeout(function(){e.layers.forEach(function(t){var e=t.node;e.style.transition="none"})},this.config.speed)},v.prototype.onMouseMove=function(t){var e=this,n=this.getValues(t);this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX("+("x"===this.config.disabledAxis?0:n.tiltY)+"deg)\n rotateY("+("y"===this.config.disabledAxis?0:n.tiltX)+"deg)\n scale3d("+this.config.scale+", "+this.config.scale+", "+this.config.scale+")\n ",window.requestAnimationFrame(function(n){e.layers.forEach(function(n){e.translateLayers(n,t.clientX,t.clientY)})})},v.prototype.onMouseLeave=function(){var t=this;this.config.reset===!0&&(this.setTransition(),this.target.style.transform="\n perspective("+this.config.perspective+"px)\n rotateX(0deg)\n rotateY(0deg)\n scale3d(1, 1, 1)\n ",this.layers.forEach(function(e){e.node.style.transition=t.config.speed+"ms "+t.config.easing,t.doTranslate(e,0,0)}))};var p={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},m=n(function(t){function e(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}var n=p,r={};for(var a in n)n.hasOwnProperty(a)&&(r[n[a]]=a);var i=t.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var s in i)if(i.hasOwnProperty(s)){if(!("channels"in i[s]))throw new Error("missing channels property: "+s);if(!("labels"in i[s]))throw new Error("missing channel labels property: "+s);if(i[s].labels.length!==i[s].channels)throw new Error("channel and label counts mismatch: "+s);var o=i[s].channels,h=i[s].labels;delete i[s].channels,delete i[s].labels,Object.defineProperty(i[s],"channels",{value:o}),Object.defineProperty(i[s],"labels",{value:h})}i.rgb.hsl=function(t){var e,n,r,a=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(a,i,s),h=Math.max(a,i,s),c=h-o;return h===o?e=0:a===h?e=(i-s)/c:i===h?e=2+(s-a)/c:s===h&&(e=4+(a-i)/c),e=Math.min(60*e,360),e<0&&(e+=360),r=(o+h)/2,n=h===o?0:r<=.5?c/(h+o):c/(2-h-o),[e,100*n,100*r]},i.rgb.hsv=function(t){var e,n,r,a=t[0],i=t[1],s=t[2],o=Math.min(a,i,s),h=Math.max(a,i,s),c=h-o;return n=0===h?0:c/h*1e3/10,h===o?e=0:a===h?e=(i-s)/c:i===h?e=2+(s-a)/c:s===h&&(e=4+(a-i)/c),e=Math.min(60*e,360),e<0&&(e+=360),r=h/255*1e3/10,[e,n,r]},i.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2],a=i.rgb.hsl(t)[0],s=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[a,100*s,100*r]},i.rgb.cmyk=function(t){var e,n,r,a,i=t[0]/255,s=t[1]/255,o=t[2]/255;return a=Math.min(1-i,1-s,1-o),e=(1-i-a)/(1-a)||0,n=(1-s-a)/(1-a)||0,r=(1-o-a)/(1-a)||0,[100*e,100*n,100*r,100*a]},i.rgb.keyword=function(t){var a=r[t];if(a)return a;var i,s=1/0;for(var o in n)if(n.hasOwnProperty(o)){var h=n[o],c=e(t,h);c<s&&(s=c,i=o)}return i},i.keyword.rgb=function(t){return n[t]},i.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92;var a=.4124*e+.3576*n+.1805*r,i=.2126*e+.7152*n+.0722*r,s=.0193*e+.1192*n+.9505*r;return[100*a,100*i,100*s]},i.rgb.lab=function(t){var e,n,r,a=i.rgb.xyz(t),s=a[0],o=a[1],h=a[2];return s/=95.047,o/=100,h/=108.883,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,e=116*o-16,n=500*(s-o),r=200*(o-h),[e,n,r]},i.hsl.rgb=function(t){var e,n,r,a,i,s=t[0]/360,o=t[1]/100,h=t[2]/100;if(0===o)return i=255*h,[i,i,i];n=h<.5?h*(1+o):h+o-h*o,e=2*h-n,a=[0,0,0];for(var c=0;c<3;c++)r=s+1/3*-(c-1),r<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[c]=255*i;return a},i.hsl.hsv=function(t){var e,n,r=t[0],a=t[1]/100,i=t[2]/100,s=a,o=Math.max(i,.01);return i*=2,a*=i<=1?i:2-i,s*=o<=1?o:2-o,n=(i+a)/2,e=0===i?2*s/(o+s):2*a/(i+a),[r,100*e,100*n]},i.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,i=e-Math.floor(e),s=255*r*(1-n),o=255*r*(1-n*i),h=255*r*(1-n*(1-i));switch(r*=255,a){case 0:return[r,h,s];case 1:return[o,r,s];case 2:return[s,r,h];case 3:return[s,o,r];case 4:return[h,s,r];case 5:return[r,s,o]}},i.hsv.hsl=function(t){var e,n,r,a=t[0],i=t[1]/100,s=t[2]/100,o=Math.max(s,.01);return r=(2-i)*s,e=(2-i)*o,n=i*o,n/=e<=1?e:2-e,n=n||0,r/=2,[a,100*n,100*r]},i.hwb.rgb=function(t){var e,n,r,a,i=t[0]/360,s=t[1]/100,o=t[2]/100,h=s+o;h>1&&(s/=h,o/=h),e=Math.floor(6*i),n=1-o,r=6*i-e,0!==(1&e)&&(r=1-r),a=s+r*(n-s);var c,l,u;switch(e){default:case 6:case 0:c=n,l=a,u=s;break;case 1:c=a,l=n,u=s;break;case 2:c=s,l=n,u=a;break;case 3:c=s,l=a,u=n;break;case 4:c=a,l=s,u=n;break;case 5:c=n,l=s,u=a}return[255*c,255*l,255*u]},i.cmyk.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,s=t[2]/100,o=t[3]/100;return e=1-Math.min(1,a*(1-o)+o),n=1-Math.min(1,i*(1-o)+o),r=1-Math.min(1,s*(1-o)+o),[255*e,255*n,255*r]},i.xyz.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,s=t[2]/100;return e=3.2406*a+i*-1.5372+s*-.4986,n=a*-.9689+1.8758*i+.0415*s,r=.0557*a+i*-.204+1.057*s,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,e=Math.min(Math.max(0,e),1),n=Math.min(Math.max(0,n),1),r=Math.min(Math.max(0,r),1),[255*e,255*n,255*r]},i.xyz.lab=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return a/=95.047,i/=100,s/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,i=i>.008856?Math.pow(i,1/3):7.787*i+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,e=116*i-16,n=500*(a-i),r=200*(i-s),[e,n,r]},i.lab.xyz=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];n=(a+16)/116,e=i/500+n,r=n-s/200;var o=Math.pow(n,3),h=Math.pow(e,3),c=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=h>.008856?h:(e-16/116)/7.787,r=c>.008856?c:(r-16/116)/7.787,e*=95.047,n*=100,r*=108.883,[e,n,r]},i.lab.lch=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return e=Math.atan2(s,i),n=360*e/2/Math.PI,n<0&&(n+=360),r=Math.sqrt(i*i+s*s),[a,r,n]},i.lch.lab=function(t){var e,n,r,a=t[0],i=t[1],s=t[2];return r=s/360*2*Math.PI,e=i*Math.cos(r),n=i*Math.sin(r),[a,e,n]},i.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:i.rgb.hsv(t)[2];if(a=Math.round(a/50),0===a)return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(s+=60),s},i.hsv.ansi16=function(t){return i.rgb.ansi16(i.hsv.rgb(t),t[2])},i.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];if(e===n&&n===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var a=16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5);return a},i.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var n=.5*(~~(t>50)+1),r=(1&e)*n*255,a=(e>>1&1)*n*255,i=(e>>2&1)*n*255;return[r,a,i]},i.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}t-=16;var n,r=Math.floor(t/36)/5*255,a=Math.floor((n=t%36)/6)/5*255,i=n%6/5*255;return[r,a,i]},i.rgb.hex=function(t){var e=((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2])),n=e.toString(16).toUpperCase();return"000000".substring(n.length)+n},i.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map(function(t){return t+t}).join(""));var r=parseInt(n,16),a=r>>16&255,i=r>>8&255,s=255&r;return[a,i,s]},i.rgb.hcg=function(t){var e,n,r=t[0]/255,a=t[1]/255,i=t[2]/255,s=Math.max(Math.max(r,a),i),o=Math.min(Math.min(r,a),i),h=s-o;return e=h<1?o/(1-h):0,n=h<=0?0:s===r?(a-i)/h%6:s===a?2+(i-r)/h:4+(r-a)/h+4,n/=6,n%=1,[360*n,100*h,100*e]},i.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return r=n<.5?2*e*n:2*e*(1-n),r<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},i.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},i.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a=[0,0,0],i=e%1*6,s=i%1,o=1-s,h=0;switch(Math.floor(i)){case 0:a[0]=1,a[1]=s,a[2]=0;break;case 1:a[0]=o,a[1]=1,a[2]=0;break;case 2:a[0]=0,a[1]=1,a[2]=s;break;case 3:a[0]=0,a[1]=o,a[2]=1;break;case 4:a[0]=s,a[1]=0,a[2]=1;break;default:a[0]=1,a[1]=0,a[2]=o}return h=(1-n)*r,[255*(n*a[0]+h),255*(n*a[1]+h),255*(n*a[2]+h)]},i.hcg.hsv=function(t){var e=t[1]/100,n=t[2]/100,r=e+n*(1-e),a=0;return r>0&&(a=e/r),[t[0],100*a,100*r]},i.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100,r=n*(1-e)+.5*e,a=0;return r>0&&r<.5?a=e/(2*r):r>=.5&&r<1&&(a=e/(2*(1-r))),[t[0],100*a,100*r]},i.hcg.hwb=function(t){var e=t[1]/100,n=t[2]/100,r=e+n*(1-e);return[t[0],100*(r-e),100*(1-r)]},i.hwb.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1-n,a=r-e,i=0;return a<1&&(i=(r-a)/(1-a)),[t[0],100*a,100*i]},i.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},i.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},i.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},i.gray.hsl=i.gray.hsv=function(t){return[0,0,t[0]]},i.gray.hwb=function(t){return[0,100,t[0]]},i.gray.cmyk=function(t){return[0,0,0,t[0]]},i.gray.lab=function(t){return[t[0],0,0]},i.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=(e<<16)+(e<<8)+e,r=n.toString(16).toUpperCase();return"000000".substring(r.length)+r},i.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]}}),b=m,y=Object.keys(b),w=function(t){for(var e=a(t),n={},r=Object.keys(e),i=r.length,o=0;o<i;o++){var h=r[o],c=e[h];null!==c.parent&&(n[h]=s(h,e))}return n},M=m,x=w,S={},k=Object.keys(M);k.forEach(function(t){S[t]={},Object.defineProperty(S[t],"channels",{value:M[t].channels}),Object.defineProperty(S[t],"labels",{value:M[t].labels});var e=x(t),n=Object.keys(e);n.forEach(function(n){var r=e[n];S[t][n]=h(r),S[t][n].raw=o(r)})});var E=S,T=function(t,e,n,r){function a(){function a(){s=Number(new Date),n.apply(h,l)}function o(){i=void 0}var h=this,c=Number(new Date)-s,l=arguments;r&&!i&&a(),i&&clearTimeout(i),void 0===r&&c>t?a():e!==!0&&(i=setTimeout(r?o:a,void 0===r?t-c:t))}var i,s=0;return"boolean"!=typeof e&&(r=n,n=e,e=void 0),a},C={stageSwitchTransition:800,stageSwitchDelay:0,stageSwitchEasing:"cubic-bezier(.86, 0, .07, 1)",disableAfterSwitching:500,stages:[]},N={scrollNumber:1,transition:200,easing:"ease",items:[]},A=new RegExp(/-?\d+(?:\.\d+)?/,"g"),I=["webkit","ms","moz",""],O=function(t,e){if("string"==typeof t&&(t=document.querySelector(t)),!t||1!==t.nodeType)throw new Error("Cannot find target dom to apply scroll effects");e=f({},[C,e]),t.style.overflow="hidden",this.target=t,this.config=e,this.animating=!1,this.switching=!1,this.stages=[],this.activeStageIndex=0,this.initStages(),this.processStages(),this.defineActiveStage(),this.addEventListeners()};O.prototype.defineActiveStage=function(){var t=this.stages[this.activeStageIndex],e=this;Object.defineProperty(this,"activeStage",{get:function(){return t},set:function(n){if(n!==t){var r=JSON.parse(JSON.stringify(t));t=n,e.activeStageIndex=e.stages.findIndex(function(t){return t===n}),e.handleActiveStageChange(),e.target.dispatchEvent(new CustomEvent("stage-change",{detail:{previous:{id:r.id,node:r.node,config:r.stageConfig,step:r.step},current:{id:n.id,node:n.node,config:n.stageConfig}}}))}}})},O.prototype.addEventListeners=function(){this.boundHandleScroll=this.handleScroll.bind(this),this.throttledHandleStepChange=T(50,!0,this.handleStepChange,!0),document.addEventListener("wheel",this.boundHandleScroll)},O.prototype.removeEventListeners=function(){document.removeEventListener("wheel",this.boundHandleScroll)},O.prototype.initStages=function(){var t=this;l(this.target,function(e){if(1===e.nodeType){var n=e.getAttribute("data-scroll-stage-id");if(n){var r=u(t.config.stages,n);if(!r)throw new Error("\n Missing scrolling config for stage id: "+n+"\n ");e.style.transition="\n "+t.config.stageSwitchTransition+"ms "+t.config.stageSwitchEasing+" "+t.config.stageSwitchDelay+"ms\n ",t.stages.push({node:e,stageConfig:f({},[N,r]),id:n,step:0})}}})},O.prototype.processStages=function(){var t=this;this.stages.forEach(function(e){t.constructor.attachNodeToItems(e),t.processItemEffects(e)})},O.attachNodeToItems=function(t){l(t.node,function(e){if(1===e.nodeType){var n=e.getAttribute("data-scroll-item-id");if(n){var r=u(t.stageConfig.items,n);if(!r)throw new Error("Missing scrolling config for item id: "+n);r.node=e}}})},O.prototype.processItemEffects=function(t){var e=this;t.stageConfig.items.forEach(function(n){n.effects.forEach(function(n){void 0===n.startAt&&(n.startAt=0),void 0===n.endAt&&(n.endAt=Number(t.stageConfig.scrollNumber)),e.constructor.processColorValues(n),n.startNumbers=(n.start.match(A)||[]).map(function(t){return Number(t)}),n.endNumbers=(n.end.match(A)||[]).map(function(t){return Number(t)}),n.strings=n.start.split(A)})})},O.getCurrentStyleValue=function(t,e){var n=t.startAt,r=t.endAt,a=t.startNumbers,i=t.endNumbers,s=t.strings,o=t.isColor;e=Math.min(r,Math.max(n,e));var h=s[0],c=-1;return a&&a.length>0&&a.forEach(function(t,a){/rgba/.test(s[a])&&(c=a+3);var l=t+(e-n)*(i[a]-t)/(r-n);o&&a!==c&&(l=Math.round(l)),h+=""+l+s[a+1]}),h},O.processColorValues=function(t){["start","end"].forEach(function(e){var n=t[e],r=g(n);if(r){if(t.isColor=!0,"hex"===r)n="\n rgb("+E.hex.rgb(n).join(",")+")\n ";else if("hsl"===r){var a=n.match(/hsla?\((.*)\)/)[1].split(/\s*,\s*/).map(function(t){return parseFloat(t)}),i=a[0],s=a[1],o=a[2],h=a[3];n="\n rgba("+E.hsl.rgb([i,s,o]).join(",")+", "+(void 0===h?1:h)+")\n "}t[e]=n}})},O.prototype.setActiveStage=function(t,e){if(void 0===e&&(e=!1),this.activeStage.id!==t){var n=this.activeStageIndex;this.activeStage.step=0;var r=u(this.stages,t)||this.stages[0],a=this.stages.findIndex(function(t){return t===r});e?(r.step=n<a?0:Number(r.stageConfig.scrollNumber),this.activeStage=r,this.handleStepChange(!1,!1)):(this.activeStage=r,this.handleStepChange(!1,!1))}},O.prototype.handleActiveStageChange=function(){var t=this;clearTimeout(this.switchingTimeout),this.switching=!0,this.stages.forEach(function(e){I.forEach(function(n){var r=n.length?n+"Transform":"transform";e.node.style[r]="translateY("+100*-t.activeStageIndex+"%)"})}),this.switchingTimeout=setTimeout(function(e){t.switching=!1},Number(this.config.stageSwitchTransition)+Number(this.config.disableAfterSwitching))},O.prototype.setStep=function(t){var e=typeof t;if("number"!==e)throw new Error("step should be a number, got "+e);if(t<0||t>Number(this.activeStage.stageConfig.scrollNumber))throw new Error("\n step should be within [0, "+this.activeStage.stageConfig.scrollNumber+"], got "+t+"\n ");this.activeStage.step!==t&&(this.activeStage.step=t,this.handleStepChange())},O.prototype.getActiveStage=function(){return this.activeStage},O.prototype.getStep=function(){return this.activeStage.step},O.prototype.handleStepChange=function(t,e){var n=this;void 0===t&&(t=!0),void 0===e&&(e=!0);var r=this.activeStage.step,a=this.activeStage.stageConfig,i=this.activeStageIndex;if(r>Number(a.scrollNumber)){if(i===this.stages.length-1)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"bottom"}})),void(this.activeStage.step=Number(a.scrollNumber));this.setActiveStage(this.stages[i+1].id,!0)}else if(r<0){if(0===i)return this.target.dispatchEvent(new CustomEvent("scroll-out",{detail:{direction:"top"}})),void(this.activeStage.step=0);this.setActiveStage(this.stages[i-1].id,!0)}else clearTimeout(this.animatingTimeout),this.animating=!0,a.items.forEach(function(e){e.node.style.transition=t?a.transition+"ms "+a.easing:"none",e.effects.forEach(function(t){e.node.style[t.property]=n.constructor.getCurrentStyleValue(t,r)})}),e&&this.target.dispatchEvent(new CustomEvent("step-change",{detail:{activeStage:{id:this.activeStage.id,node:this.activeStage.node,config:a},current:r}})),this.animatingTimeout=setTimeout(function(t){n.animating=!1},t?Number(a.transition):0)},O.prototype.handleScroll=function(t){t.preventDefault(),this.animating||this.switching||(this.activeStage.step+=t.deltaY>0?1:-1,this.throttledHandleStepChange())},O.prototype.destroy=function(){this.removeEventListeners()},O.prototype.restore=function(){this.addEventListeners()},t.Hover=v,t.Scroll=O,Object.defineProperty(t,"__esModule",{value:!0})}); |
{ | ||
"name": "perspective.js", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Parallax scrolling effect. And more.", | ||
@@ -10,3 +10,4 @@ "main": "lib/perspective.common.js", | ||
"build:examples": "node build/examples.js", | ||
"dist": "npm run build:package && npm run build:examples" | ||
"dist": "npm run build:package && npm run build:examples", | ||
"pub": "npm run dist && sh release.sh" | ||
}, | ||
@@ -13,0 +14,0 @@ "repository": { |
@@ -7,8 +7,8 @@ import walk from 'dom-walk' | ||
max: 20, | ||
reverse: false, | ||
reverseTilt: false, | ||
perspective: 1000, | ||
easing: 'cubic-bezier(.03, .98, .52, .99)', | ||
scale: '1', | ||
speed: '300', | ||
disabledAxis: null, | ||
scale: 1, | ||
speed: 300, | ||
disabledAxis: '', | ||
reset: true | ||
@@ -35,8 +35,8 @@ } | ||
if (layer) { | ||
const configSpeed = config.layers[Number(layer)].speed | ||
if (!configSpeed) throw new Error(`Missing translate config for ${ layer }`) | ||
const configMultiple = config.layers[Number(layer)].multiple | ||
if (!configMultiple) throw new Error(`Missing translate config for ${ layer }`) | ||
this.layers.push(merge({ | ||
node, | ||
speed: configSpeed === undefined ? 0.2 : configSpeed, | ||
reverse: !!config.layers[Number(layer)].reverse | ||
multiple: configMultiple === undefined ? 0.2 : configMultiple, | ||
reverseTranslate: !!config.layers[Number(layer)].reverseTranslate | ||
}, [this.constructor.getInitialTransformMatrix(node)])) | ||
@@ -104,5 +104,5 @@ } | ||
translateLayers(layer, x, y) { | ||
const { speed, reverse } = layer | ||
const offsetX = Math.floor(speed * (0.5 * document.body.clientWidth + (reverse ? -1 : 1) * x)) | ||
const offsetY = Math.floor(speed * (0.5 * document.body.clientHeight + (reverse ? -1 : 1) * y)) | ||
const { multiple, reverseTranslate } = layer | ||
const offsetX = Math.floor(multiple * (0.5 * document.body.clientWidth + (reverseTranslate ? -1 : 1) * x)) | ||
const offsetY = Math.floor(multiple * (0.5 * document.body.clientHeight + (reverseTranslate ? -1 : 1) * y)) | ||
this.doTranslate(layer, offsetX, offsetY) | ||
@@ -118,4 +118,4 @@ } | ||
const tiltX = (this.config.reverse ? -1 : 1) * (this.config.max / 2 - x * this.config.max).toFixed(2) | ||
const tiltY = (this.config.reverse ? -1 : 1) * (y * this.config.max - this.config.max / 2).toFixed(2) | ||
const tiltX = (this.config.reverseTilt ? -1 : 1) * (this.config.max / 2 - x * this.config.max).toFixed(2) | ||
const tiltY = (this.config.reverseTilt ? -1 : 1) * (y * this.config.max - this.config.max / 2).toFixed(2) | ||
return { | ||
@@ -122,0 +122,0 @@ tiltX, |
@@ -219,3 +219,3 @@ import walk from 'dom-walk' | ||
const type = typeof step | ||
if (type !== 'number') throw new Error(`step should be not a number, got ${ type }`) | ||
if (type !== 'number') throw new Error(`step should be a number, got ${ type }`) | ||
if (step < 0 || step > Number(this.activeStage.stageConfig.scrollNumber)) { | ||
@@ -300,3 +300,11 @@ throw new Error(` | ||
} | ||
destroy() { | ||
this.removeEventListeners() | ||
} | ||
restore() { | ||
this.addEventListeners() | ||
} | ||
} | ||
export default Scroll |
Sorry, the diff of this file is not supported yet
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
22
691
167960