-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimate.min.js
More file actions
7 lines (6 loc) · 2.09 KB
/
Copy pathanimate.min.js
File metadata and controls
7 lines (6 loc) · 2.09 KB
1
2
3
4
5
6
7
/*!
* AnimateJS v0.0.2 (https://github.com/RodnyE/AnimateJS)
* Copyright 2022 Rodny Estrada
* Licensed under the MIT license
*/
(Animate=function(t){this.duration=t.duration,this.draw=t.draw,this.statics=t.statics,this.state="stoped",this.frame=0,this.eventHandler={play:function(){},stop:function(){},pause:function(){},end:function(){}};let n=t.fps;"number"==typeof n?(this.requestAnimationFrame=function(t){setTimeout(function(){t(performance.now())},1e3/n)},this.fps=n):this.fps="auto";let i=t.timing||Animate.LINEAR;switch(t.erase){case"out":this.timing=function(t){return 1-i(1-t)};break;case"both":case"in-out":this.timing=function(t){return t<=.5?i(2*t)/2:(2-i(2*(1-t)))/2};break;default:this.timing=i}}).prototype.renderFrame=function(t){let n=(t-this.timeStart)/this.duration;n>=1&&(n=1),this.frame=n,this.draw(this.timing(n),this.statics),n<1?"playing"==this.state&&this.requestAnimationFrame(this.renderFrame.bind(this)):(this.state="stoped",this.eventHandler.end())},Animate.prototype.play=function(){let t=performance.now();"paused"==this.state&&(t-=this.duration*this.frame),this.timeStart=t,this.state="playing",this.eventHandler.play(),this.renderFrame(t)},Animate.prototype.stop=function(){this.state="stoped",this.eventHandler.stop()},Animate.prototype.pause=function(){"playing"==this.state&&(this.state="paused",this.eventHandler.pause())},Animate.prototype.toFrame=function(t){let n=performance.now();this.timeStart=n-this.duration*t,this.frame=t,this.renderFrame(n)},Animate.prototype.on=function(t,n){this.eventHandler[t]=n},Animate.prototype.requestAnimationFrame=function(t){window.requestAnimationFrame(t)},Animate.LINEAR=function(t){return t},Animate.REVERSE=function(t){return 1-t},Animate.QUAD=function(t){return Math.pow(t,2)},Animate.QUBIC=function(t){return Math.pow(t,3)},Animate.CIRC=function(t){return 1-Math.sin(Math.acos(t))},Animate.ARROW=function(t){return Math.pow(t,2)*(2.5*t-1.5)},Animate.BOUNCE=function(t){for(let n=0,i=1;;n+=i,i/=2)if(t>=(7-4*n)/11)return-Math.pow((11-6*n-11*t)/4,2)+Math.pow(i,2)},Animate.ELASTIC=function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*1.5/3*t)};