1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.KUTE=e()}(this,function(){"use strict";for(var t,p="undefined"!=typeof global?global:window,a=p.performance,n=document.body,r=[],i=null,g="length",m="split",w="indexOf",v="replace",y="offsetWidth",I="offsetHeight",o="options",b="valuesStart",M="valuesEnd",u="valuesRepeat",O="element",h="playing",c="duration",l="delay",f="offset",k="repeat",T="repeatDelay",x="yoyo",E="easing",P="chain",Y="style",s="data-tweening",X="getElementsByTagName",e="addEventListener",C=["color","backgroundColor"],F=["top","left","width","height"],A=["translate3d","translateX","translateY","translateZ","rotate","translate","rotateX","rotateY","rotateZ","skewX","skewY","scale"],_=["opacity"],S=C.concat(_,F,A),Z={},$=0,B=S[g];$<B;$++)t=S[$],-1!==C[w](t)?Z[t]="rgba(0,0,0,0)":-1!==F[w](t)?Z[t]=0:"translate3d"===t?Z[t]=[0,0,0]:"translate"===t?Z[t]=[0,0]:"rotate"===t||/X|Y|Z/.test(t)?Z[t]=0:"scale"!==t&&"opacity"!==t||(Z[t]=1);function q(){for(var t,e=["Moz","moz","Webkit","webkit","O","o","Ms","ms"],r=0,i=e[g];r<i;r++)if(e[r]+"Transform"in n[Y]){t=e[r];break}return t}function Q(t){var e=!(t in n[Y]),r=q();return e?r+(t.charAt(0).toUpperCase()+t.slice(1)):t}function z(t,e){var r;if(null===(r=e?t instanceof Object||"object"==typeof t?t:document.querySelectorAll(t):"object"==typeof t?t:document.querySelector(t))&&"window"!==t)throw new TypeError("Element not found or incorrect selector: "+t);return r}function j(t){return 180*t/Math.PI}function D(t,e){for(var r,i=parseInt(t)||0,n=["px","%","deg","rad","em","rem","vh","vw"],s=0;s<n[g];s++)if("string"==typeof t&&-1!==t[w](n[s])){r=n[s];break}return{v:i,u:r=void 0!==r?r:e?"deg":"px"}}function R(t){if(/rgb|rgba/.test(t)){var e=t[v](/\s|\)/,"")[m]("(")[1][m](","),r=e[3]?e[3]:null;return r?{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2]),a:parseFloat(r)}:{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2])}}if(/^#/.test(t)){var i=V(t);return{r:i.r,g:i.g,b:i.b}}if(/transparent|none|initial|inherit/.test(t))return{r:0,g:0,b:0,a:0};if(!/^#|^rgb/.test(t)){var n=document[X]("head")[0];n[Y].color=t;var s=p.getComputedStyle(n,null).color;return s=/rgb/.test(s)?s[v](/[^\d,]/g,"")[m](","):[0,0,0],n[Y].color="",{r:parseInt(s[0]),g:parseInt(s[1]),b:parseInt(s[2])}}}function H(t,e,r){return"#"+((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1)}function N(t,e){var r=t[Y],i=p.getComputedStyle(t,null)||t.currentStyle,n=Q(e),s=r[e]&&!/auto|initial|none|unset/.test(r[e])?r[e]:i[n];if("transform"!==e&&(n in i||n in r)){if(s){if("filter"!==n)return s;var a=parseInt(s[m]("=")[1][v](")",""));return parseFloat(a/100)}return Z[e]}}function L(t){var e=r[w](t);-1!==e&&r.splice(e,1)}function U(t,e){var r="start"===e?this[b]:this[M],i={},n={},s={},a={};for(var o in t)if(-1!==A[w](o)){var u=["X","Y","Z"];if(/^translate(?:[XYZ]|3d)$/.test(o)){for(var h=0;h<3;h++){var c=u[h];/3d/.test(o)?s["translate"+c]=yt.transform.call(this,"translate"+c,t[o][h]):s["translate"+c]="translate"+c in t?yt.transform.call(this,"translate"+c,t["translate"+c]):0}a.translate=s}else if(/^rotate(?:[XYZ])$|^skew(?:[XY])$/.test(o)){for(var l=/rotate/.test(o)?"rotate":"skew",f="rotate"==l?n:i,p=0;p<3;p++){var v=u[p];void 0!==t[l+v]&&"skewZ"!==o&&(f[l+v]=yt.transform.call(this,l+v,t[l+v]))}a[l]=f}else/(rotate|translate|scale)$/.test(o)&&(a[o]=yt.transform.call(this,o,t[o]));r[it]=a}else-1!==F[w](o)?r[o]=yt.boxModel.call(this,o,t[o]):-1!==_[w](o)||"scroll"===o?r[o]=yt.unitless.call(this,o,t[o]):-1!==C[w](o)?r[o]=yt.colors.call(this,o,t[o]):o in yt&&(r[o]=yt[o].call(this,o,t[o]))}function W(t){var e=n.getAttribute(s);e&&"scroll"===e&&t.preventDefault()}function G(t){return"function"==typeof t?t:"string"==typeof t?Ot[t]:void 0}function K(){var t={},e=function(t){if(t){for(var e=t[Y].cssText[v](/\s/g,"")[m](";"),r={},i=0,n=e[g];i<n;i++)if(/transform/i.test(e[i]))for(var s=e[i][m](":")[1][m](")"),a=0,o=s[g]-1;a<o;a++){var u=s[a][m]("("),h=u[0],c=u[1];-1!==A[w](h)&&(r[h]=/translate3d/.test(h)?c[m](","):c)}return r}}(this[O]),r=["rotate","skew"],i=["X","Y","Z"];for(var n in this[b])if(-1!==A[w](n)){var s=/(rotate|translate|scale)$/.test(n);if(/translate/.test(n)&&"translate"!==n)t.translate3d=e.translate3d||Z[n];else if(s)t[n]=e[n]||Z[n];else if(!s&&/rotate|skew/.test(n))for(var a=0;a<2;a++)for(var o=0;o<3;o++){var u=r[a]+i[o];-1!==A[w](u)&&u in this[b]&&(t[u]=e[u]||Z[u])}}else if("scroll"!==n)if("opacity"===n&&at){var h=N(this[O],"filter");t.opacity="number"==typeof h?h:Z.opacity}else-1!==S[w](n)?t[n]=N(this[O],n)||d[n]:t[n]=n in mt?mt[n].call(this,n,this[b][n]):0;else t[n]=this[O]===st?p.pageYOffset||st.scrollTop:this[O].scrollTop;for(var c in e)-1===A[w](c)||c in this[b]||(t[c]=e[c]||Z[c]);if(this[b]={},U.call(this,t,"start"),it in this[M])for(var l in this[b][it])if("perspective"!==l)if("object"==typeof this[b][it][l])for(var f in this[b][it][l])void 0===this[M][it][l]&&(this[M][it][l]={}),"number"==typeof this[b][it][l][f]&&void 0===this[M][it][l][f]&&(this[M][it][l][f]=this[b][it][l][f]);else"number"==typeof this[b][it][l]&&void 0===this[M][it][l]&&(this[M][it][l]=this[b][it][l])}var J={duration:700,delay:0,offset:0,repeat:0,repeatDelay:0,yoyo:!1,easing:"linear",keepHex:!1},V=function(t){t=t[v](/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,r,i){return e+e+r+r+i+i});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null},tt="ontouchstart"in p||navigator&&navigator.msMaxTouchPoints||!1?"touchstart":"mousewheel",et=p.requestAnimationFrame||p.webkitRequestAnimationFrame||function(t){return setTimeout(t,16)},rt=p.cancelAnimationFrame||p.webkitCancelRequestAnimationFrame||function(t){return clearTimeout(t)},it=Q("transform"),nt=document[X]("HTML")[0],st=navigator&&/(EDGE|Mac)/i.test(navigator.userAgent)?n:nt,at=8===(!(!navigator||null===new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent))&&parseFloat(RegExp.$1)),ot=p.Interpolate={},ut=ot.number=function(t,e,r){return(t=+t)+(e-=t)*r},ht=(ot.unit=function(t,e,r,i){return(t=+t)+(e-=t)*i+r},ot.color=function(t,e,r,i){var n,s={};for(n in e)s[n]="a"!==n?ut(t[n],e[n],r)>>0||0:t[n]&&e[n]?(100*ut(t[n],e[n],r)>>0)/100:null;return i?H(s.r,s.g,s.b):s.a?"rgba("+s.r+","+s.g+","+s.b+","+s.a+")":"rgb("+s.r+","+s.g+","+s.b+")"}),ct=ot.translate=function(t,e,r,i){var n={};for(var s in e)n[s]=(t[s]===e[s]?e[s]:(1e3*(t[s]+(e[s]-t[s])*i)>>0)/1e3)+r;return n.x||n.y?"translate("+n.x+","+n.y+")":"translate3d("+n.translateX+","+n.translateY+","+n.translateZ+")"},lt=ot.rotate=function(t,e,r,i){var n={};for(var s in e)n[s]="z"===s?"rotate("+(1e3*(t[s]+(e[s]-t[s])*i)>>0)/1e3+r+")":s+"("+(1e3*(t[s]+(e[s]-t[s])*i)>>0)/1e3+r+")";return n.z?n.z:(n.rotateX||"")+(n.rotateY||"")+(n.rotateZ||"")},ft=ot.skew=function(t,e,r,i){var n={};for(var s in e)n[s]=s+"("+(1e3*(t[s]+(e[s]-t[s])*i)>>0)/1e3+r+")";return(n.skewX||"")+(n.skewY||"")},pt=ot.scale=function(t,e,r){return"scale("+(1e3*(t+(e-t)*r)>>0)/1e3+")"},vt={},dt=function(t){for(var e=0;e<r[g];)gt.call(r[e],t)?e++:r.splice(e,1);i=et(dt)},gt=function(t){if((t=t||a.now())<this._startTime&&this[h])return!0;var e=Math.min((t-this._startTime)/this[o][c],1),r=this[o][E](e);for(var i in this[M])vt[i](this[O],i,this[b][i],this[M][i],r,this[o]);if(this[o].update&&this[o].update.call(this),1!==e)return!0;if(0<this[o][k])return isFinite(this[o][k])&&this[o][k]--,this[o][x]&&(this.reversed=!this.reversed,It.call(this)),this._startTime=this[o][x]&&!this.reversed?t+this[o][T]:t,!0;this[o].complete&&this[o].complete.call(this),Mt.call(this);for(var n=0,s=this[o][P][g];n<s;n++)this[o][P][n].start();return bt.call(this),!1},mt={},wt={},yt={boxModel:function(t,e){t in vt||(vt[t]=function(t,e,r,i,n){t[Y][e]=(.99<n||n<.01?(10*ut(r,i,n)>>0)/10:ut(r,i,n)>>0)+"px"});var r=D(e),i="height"===t?I:y;return"%"===r.u?r.v*this[O][i]/100:r.v},transform:function(t,e){if(it in vt||(vt[it]=function(t,e,r,i,n,s){t[Y][e]=(r.perspective||"")+("translate"in r?ct(r.translate,i.translate,"px",n):"")+("rotate"in r?lt(r.rotate,i.rotate,"deg",n):"")+("skew"in r?ft(r.skew,i.skew,"deg",n):"")+("scale"in r?pt(r.scale,i.scale,n):"")}),/translate/.test(t)){if("translate3d"===t){var r=e[m](","),i=D(r[0]),n=D(r[1],t3d2=D(r[2]));return{translateX:"%"===i.u?i.v*this[O][y]/100:i.v,translateY:"%"===n.u?n.v*this[O][I]/100:n.v,translateZ:"%"===t3d2.u?t3d2.v*(this[O][I]+this[O][y])/200:t3d2.v}}if(/^translate(?:[XYZ])$/.test(t)){var s=D(e),a=/X/.test(t)?this[O][y]/100:/Y/.test(t)?this[O][I]/100:(this[O][y]+this[O][I])/200;return"%"===s.u?s.v*a:s.v}if("translate"===t){var o,u="string"==typeof e?e[m](","):e,h={},c=D(u[0]),l=u[g]?D(u[1]):{v:0,u:"px"};return u instanceof Array?(h.x="%"===c.u?c.v*this[O][y]/100:c.v,h.y="%"===l.u?l.v*this[O][I]/100:l.v):(o=D(u),h.x="%"===o.u?o.v*this[O][y]/100:o.v,h.y=0),h}}else if(/rotate|skew/.test(t)){if(/^rotate(?:[XYZ])$|skew(?:[XY])$/.test(t)){var f=D(e,!0);return"rad"===f.u?j(f.v):f.v}if("rotate"===t){var p={},v=D(e,!0);return p.z="rad"===v.u?j(v.v):v.v,p}}else if("scale"===t)return parseFloat(e)},unitless:function(t,e){return!/scroll/.test(t)||t in vt?"opacity"===t&&(t in vt||(vt[t]=at?function(t,e,r,i,n){t[Y].filter="alpha(opacity="+(100*ut(r,i,n)>>0)+")"}:function(t,e,r,i,n){t[Y].opacity=(100*ut(r,i,n)>>0)/100})):vt[t]=function(t,e,r,i,n){t.scrollTop=ut(r,i,n)>>0},parseFloat(e)},colors:function(t,e){return t in vt||(vt[t]=function(t,e,r,i,n,s){t[Y][e]=ht(r,i,n,s.keepHex)}),R(e)}},It=function(){if(this[o][x])for(var t in this[M]){var e=this[u][t];this[u][t]=this[M][t],this[M][t]=e,this[b][t]=this[u][t]}},bt=function(){0<this[k]&&(this[o][k]=this[k]),this[o][x]&&!0===this.reversed&&(It.call(this),this.reversed=!1),this[h]=!1,setTimeout(function(){!r[g]&&i&&(rt(i),i=null)},64)},Mt=function(){"scroll"in this[M]&&n.getAttribute(s)&&n.removeAttribute(s)},Ot=p.Easing={};Ot.linear=function(t){return t},Ot.easingSinusoidalIn=function(t){return 1-Math.cos(t*Math.PI/2)},Ot.easingSinusoidalOut=function(t){return Math.sin(t*Math.PI/2)},Ot.easingSinusoidalInOut=function(t){return-.5*(Math.cos(Math.PI*t)-1)},Ot.easingQuadraticIn=function(t){return t*t},Ot.easingQuadraticOut=function(t){return t*(2-t)},Ot.easingQuadraticInOut=function(t){return t<.5?2*t*t:(4-2*t)*t-1},Ot.easingCubicIn=function(t){return t*t*t},Ot.easingCubicOut=function(t){return--t*t*t+1},Ot.easingCubicInOut=function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},Ot.easingQuarticIn=function(t){return t*t*t*t},Ot.easingQuarticOut=function(t){return 1- --t*t*t*t},Ot.easingQuarticInOut=function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},Ot.easingQuinticIn=function(t){return t*t*t*t*t},Ot.easingQuinticOut=function(t){return 1+--t*t*t*t*t},Ot.easingQuinticInOut=function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},Ot.easingCircularIn=function(t){return-(Math.sqrt(1-t*t)-1)},Ot.easingCircularOut=function(t){return Math.sqrt(1- --t*t)},Ot.easingCircularInOut=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},Ot.easingExponentialIn=function(t){return Math.pow(2,10*(t-1))-.001},Ot.easingExponentialOut=function(t){return 1-Math.pow(2,-10*t)},Ot.easingExponentialInOut=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))},Ot.easingBackIn=function(t){return t*t*(2.70158*t-1.70158)},Ot.easingBackOut=function(t){return--t*t*(2.70158*t+1.70158)+1},Ot.easingBackInOut=function(t){var e=2.5949095;return(t*=2)<1?t*t*((1+e)*t-e)*.5:.5*((t-=2)*t*((1+e)*t+e)+2)},Ot.easingElasticIn=function(t){var e,r=.1;return 0===t?0:1===t?1:(e=!r||r<1?(r=1,.1):.4*Math.asin(1/r)/Math.PI*2,-(r*Math.pow(2,10*--t)*Math.sin((t-e)*Math.PI*2/.4)))},Ot.easingElasticOut=function(t){var e,r=.1;return 0===t?0:1===t?1:(e=!r||r<1?(r=1,.1):.4*Math.asin(1/r)/Math.PI*2,r*Math.pow(2,-10*t)*Math.sin((t-e)*Math.PI*2/.4)+1)},Ot.easingElasticInOut=function(t){var e,r=.1;return 0===t?0:1===t?1:(e=!r||r<1?(r=1,.1):.4*Math.asin(1/r)/Math.PI*2,(t*=2)<1?r*Math.pow(2,10*--t)*Math.sin((t-e)*Math.PI*2/.4)*-.5:r*Math.pow(2,-10*--t)*Math.sin((t-e)*Math.PI*2/.4)*.5+1)},Ot.easingBounceIn=function(t){return 1-Ot.easingBounceOut(1-t)},Ot.easingBounceOut=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},Ot.easingBounceInOut=function(t){return t<.5?.5*Ot.easingBounceIn(2*t):.5*Ot.easingBounceOut(2*t-1)+.5};function kt(t,e,r,i){for(var n in this[O]="scroll"in r&&null==t?st:t,this[h]=!1,this.reversed=!1,this.paused=!1,this._startTime=null,this._pauseTime=null,this._startFired=!1,this[o]={},i)this[o][n]=i[n];if(this[o].rpr=i.rpr||!1,this[u]={},this[M]={},this[b]={},U.call(this,r,"end"),this[o].rpr?this[b]=e:U.call(this,e,"start"),void 0!==this[o].perspective&&it in this[M]){var s="perspective("+parseInt(this[o].perspective)+"px)";this[M][it].perspective=s}for(var a in this[M])a in wt&&!this[o].rpr&&wt[a].call(this);this[o][P]=[],this[o][E]=G(i[E])||Ot[J[E]]||Ot.linear,this[o][k]=i[k]||J[k],this[o][T]=i[T]||J[T],this[o][x]=i[x]||J[x],this[o][c]=i[c]||J[c],this[o][l]=i[l]||J[l],this[k]=this[o][k]}function Tt(t,e,r){this.tweens=[];for(var i=[],n=0,s=t[g];n<s;n++)i[n]=r||{},r[l]=r[l]||J[l],i[n][l]=0<n?r[l]+(r[f]||J[f]):r[l],this.tweens.push(Et(t[n],e,i[n]))}function xt(t,e,r,i){this.tweens=[];for(var n=[],s=0,a=t[g];s<a;s++)n[s]=i||{},i[l]=i[l]||J[l],n[s][l]=0<s?i[l]+(i[f]||J[f]):i[l],this.tweens.push(Pt(t[s],e,r,n[s]))}kt.prototype={start:function(t){for(var e in function(){"scroll"in this[M]&&!n.getAttribute(s)&&n.setAttribute(s,"scroll")}.call(this),this[o].rpr&&K.apply(this),function(){var t=this[O],e=this[o];void 0!==e.perspective&&it in this[M]&&(this[b][it].perspective=this[M][it].perspective),void 0===e.transformOrigin||"svgTransform"in this[M]||(t[Y][Q("transformOrigin")]=e.transformOrigin),void 0!==e.perspectiveOrigin&&(t[Y][Q("perspectiveOrigin")]=e.perspectiveOrigin),void 0!==e.parentPerspective&&(t.parentNode[Y][Q("perspective")]=e.parentPerspective+"px"),void 0!==e.parentPerspectiveOrigin&&(t.parentNode[Y][Q("perspectiveOrigin")]=e.parentPerspectiveOrigin)}.apply(this),this[M])e in wt&&this[o].rpr&&wt[e].call(this),this[u][e]=this[b][e];return r.push(this),this[h]=!0,this.paused=!1,this._startFired=!1,this._startTime=t||a.now(),this._startTime+=this[o][l],this._startFired||(this[o].start&&this[o].start.call(this),this._startFired=!0),i||dt(),this},play:function(){var t;return this.paused&&this[h]&&(this.paused=!1,this[o].resume&&this[o].resume.call(this),this._startTime+=a.now()-this._pauseTime,t=this,r.push(t),i||dt()),this},resume:function(){return this.play()},pause:function(){return!this.paused&&this[h]&&(L(this),this.paused=!0,this._pauseTime=a.now(),this[o].pause&&this[o].pause.call(this)),this},stop:function(){return!this.paused&&this[h]&&(L(this),this[h]=!1,this.paused=!1,Mt.call(this),this[o].stop&&this[o].stop.call(this),this.stopChainedTweens(),bt.call(this)),this},chain:function(){return this[o][P]=arguments,this},stopChainedTweens:function(){for(var t=0,e=this[o][P][g];t<e;t++)this[o][P][t].stop()}},Tt.prototype=xt.prototype={start:function(t){t=t||a.now();for(var e=0,r=this.tweens[g];e<r;e++)this.tweens[e].start(t);return this},stop:function(){for(var t=0,e=this.tweens[g];t<e;t++)this.tweens[t].stop();return this},pause:function(){for(var t=0,e=this.tweens[g];t<e;t++)this.tweens[t].pause();return this},chain:function(){return this.tweens[this.tweens[g]-1][o][P]=arguments,this},play:function(){for(var t=0,e=this.tweens[g];t<e;t++)this.tweens[t].play();return this},resume:function(){return this.play()}};var Et=function(t,e,r){return(r=r||{}).rpr=!0,new kt(z(t),e,e,r)},Pt=function(t,e,r,i){return i=i||{},new kt(z(t),e,r,i)};return document[e](tt,W,!1),document[e]("mouseenter",W,!1),{property:Q,getPrefix:q,selector:z,processEasing:G,defaultOptions:J,to:Et,fromTo:Pt,allTo:function(t,e,r){return new Tt(z(t,!0),e,r)},allFromTo:function(t,e,r,i){return new xt(z(t,!0),e,r,i)},ticker:dt,tick:i,tweens:r,update:gt,dom:vt,parseProperty:yt,prepareStart:mt,crossCheck:wt,Tween:kt,truD:D,truC:R,rth:H,htr:V,getCurrentStyle:N}}); |