-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVivum.min.js
5 lines (5 loc) · 5.52 KB
/
Vivum.min.js
1
2
3
4
5
/* Vivum
* A micro JavaScript library for beautiful animations.
* Vivum Copyright (c) FelisPhasma 2014, 2017
*/
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)}}(),function(e,f){function g(u){return null==u?u+"":"object"==("undefined"==typeof u?"undefined":_typeof(u))||"function"==typeof u?m[n.call(u)]||"object":"undefined"==typeof u?"undefined":_typeof(u)}function h(){if(0==q.length)return void(r=!1);e.requestAnimFrame(h);for(var u,v,w,x=0,y=q.length;x<y;x++){if(w=q[x],v=o(),w.toAbort){q.splice(x,1),y--,x--;continue}u=k[w.easing](v-w.start,w.from,w.diff,w.duration),w.action(u),v>=w.end&&(q.splice(x,1),y--,x--,w.complete(w.to))}}function j(u,v){for(var w=["from","to","duration"],x=[0,1,"default"],z=0,A=w.length;z<A;z++)u[w[z]]=parseFloat(u[w[z]]),u[w[z]]==NaN&&(u[w[z]]=x[z]);if(u.complete=u.complete||function(){},"function"!=g(u.complete)){throw new Error("Vivum - Animation complete not a function")}if("function"!=g(v)){throw new Error("Vivum - Animation action must be defined and be a function")}if(u.easing==f)u.easing="linear";else if(k[u.easing]==f){throw new Error("Vivum - unknown easing \""+u.easing+"\"")}var y=o();q.push({start:y,end:y+u.duration,toAbort:!1,easing:u.easing,from:u.from,to:u.to,diff:u.to-u.from,duration:u.duration,action:v,complete:u.complete}),r||(r=!0,h())}var k={linear:function linear(u,v,w,x){return w*(u/x)+v},easeInQuad:function easeInQuad(u,v,w,x){return w*(u/=x)*u+v},easeOutQuad:function easeOutQuad(u,v,w,x){return-w*(u/=x)*(u-2)+v},easeInOutQuad:function easeInOutQuad(u,v,w,x){return 1>(u/=x/2)?w/2*u*u+v:-w/2*(--u*(u-2)-1)+v},easeInCubic:function easeInCubic(u,v,w,x){return w*(u/=x)*u*u+v},easeOutCubic:function easeOutCubic(u,v,w,x){return w*((u=u/x-1)*u*u+1)+v},easeInOutCubic:function easeInOutCubic(u,v,w,x){return 1>(u/=x/2)?w/2*u*u*u+v:w/2*((u-=2)*u*u+2)+v},easeInQuart:function easeInQuart(u,v,w,x){return w*(u/=x)*u*u*u+v},easeOutQuart:function easeOutQuart(u,v,w,x){return-w*((u=u/x-1)*u*u*u-1)+v},easeInOutQuart:function easeInOutQuart(u,v,w,x){return 1>(u/=x/2)?w/2*u*u*u*u+v:-w/2*((u-=2)*u*u*u-2)+v},easeInQuint:function easeInQuint(u,v,w,x){return w*(u/=x)*u*u*u*u+v},easeOutQuint:function easeOutQuint(u,v,w,x){return w*((u=u/x-1)*u*u*u*u+1)+v},easeInOutQuint:function easeInOutQuint(u,v,w,x){return 1>(u/=x/2)?w/2*u*u*u*u*u+v:w/2*((u-=2)*u*u*u*u+2)+v},easeInSine:function easeInSine(u,v,w,x){return-w*Math.cos(u/x*(Math.PI/2))+w+v},easeOutSine:function easeOutSine(u,v,w,x){return w*Math.sin(u/x*(Math.PI/2))+v},easeInOutSine:function easeInOutSine(u,v,w,x){return-w/2*(Math.cos(Math.PI*u/x)-1)+v},easeInExpo:function easeInExpo(u,v,w,x){return 0==u?v:w*Math.pow(2,10*(u/x-1))+v},easeOutExpo:function easeOutExpo(u,v,w,x){return u==x?v+w:w*(-Math.pow(2,-10*u/x)+1)+v},easeInOutExpo:function easeInOutExpo(u,v,w,x){return 0==u?v:u==x?v+w:1>(u/=x/2)?w/2*Math.pow(2,10*(u-1))+v:w/2*(-Math.pow(2,-10*--u)+2)+v},easeInCirc:function easeInCirc(u,v,w,x){return-w*(Math.sqrt(1-(u/=x)*u)-1)+v},easeOutCirc:function easeOutCirc(u,v,w,x){return w*Math.sqrt(1-(u=u/x-1)*u)+v},easeInOutCirc:function easeInOutCirc(u,v,w,x){return 1>(u/=x/2)?-w/2*(Math.sqrt(1-u*u)-1)+v:w/2*(Math.sqrt(1-(u-=2)*u)+1)+v},easeInElastic:function easeInElastic(u,v,w,x){var y=1.70158,z=0,A=w;if(0==u)return v;if(1==(u/=x))return v+w;if(z||(z=.3*x),A<Math.abs(w)){A=w;var y=z/4}else var y=z/(2*Math.PI)*Math.asin(w/A);return-(A*Math.pow(2,10*(u-=1))*Math.sin((u*x-y)*(2*Math.PI)/z))+v},easeOutElastic:function easeOutElastic(u,v,w,x){var y=1.70158,z=0,A=w;if(0==u)return v;if(1==(u/=x))return v+w;if(z||(z=.3*x),A<Math.abs(w)){A=w;var y=z/4}else var y=z/(2*Math.PI)*Math.asin(w/A);return A*Math.pow(2,-10*u)*Math.sin((u*x-y)*(2*Math.PI)/z)+w+v},easeInOutElastic:function easeInOutElastic(u,v,w,x){var y=1.70158,z=0,A=w;if(0==u)return v;if(2==(u/=x/2))return v+w;if(z||(z=x*(.3*1.5)),A<Math.abs(w)){A=w;var y=z/4}else var y=z/(2*Math.PI)*Math.asin(w/A);return 1>u?-.5*(A*Math.pow(2,10*(u-=1))*Math.sin((u*x-y)*(2*Math.PI)/z))+v:.5*(A*Math.pow(2,-10*(u-=1))*Math.sin((u*x-y)*(2*Math.PI)/z))+w+v},easeInBack:function easeInBack(u,v,w,x,y){return y==f&&(y=1.70158),w*(u/=x)*u*((y+1)*u-y)+v},easeOutBack:function easeOutBack(u,v,w,x,y){return y==f&&(y=1.70158),w*((u=u/x-1)*u*((y+1)*u+y)+1)+v},easeInOutBack:function easeInOutBack(u,v,w,x,y){return y==f&&(y=1.70158),1>(u/=x/2)?w/2*(u*u*(((y*=1.525)+1)*u-y))+v:w/2*((u-=2)*u*(((y*=1.525)+1)*u+y)+2)+v},easeInBounce:function easeInBounce(u,v,w,x){return w-k.easeOutBounce(x-u,0,w,x)+v},easeOutBounce:function easeOutBounce(u,v,w,x){if((u/=x)<1/2.75)return w*(7.5625*u*u)+v;return u<2/2.75?w*(7.5625*(u-=1.5/2.75)*u+.75)+v:u<2.5/2.75?w*(7.5625*(u-=2.25/2.75)*u+.9375)+v:w*(7.5625*(u-=2.625/2.75)*u+.984375)+v},easeInOutBounce:function easeInOutBounce(u,v,w,x){return u<x/2?.5*k.easeInBounce(2*u,0,w,x)+v:.5*k.easeOutBounce(2*u-x,0,w,x)+.5*w+v}},m={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error"},n=m.toString,o=function(){return Date.now}(),q=[],r=!1;j.speeds={slow:600,fast:200,def:400,default:400},j.easings=k,e.Vivum=j}(window);