Created
March 22, 2010 09:57
-
-
Save remy/339928 to your computer and use it in GitHub Desktop.
Easing functions for Emile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var easing = { | |
elastic: function(pos){return -1*Math.pow(4,-8*pos)*Math.sin((pos*6-1)*(2*Math.PI)/2)+1}, | |
swingFromTo:function(pos){var s=1.70158;return((pos/=0.5)<1)?0.5*(pos*pos*(((s*=(1.525))+1)*pos-s)):0.5*((pos-=2)*pos*(((s*=(1.525))+1)*pos+s)+2)}, | |
swingFrom:function(pos){var s=1.70158;return pos*pos*((s+1)*pos-s)}, | |
swingTo:function(pos){var s=1.70158;return(pos-=1)*pos*((s+1)*pos+s)+1}, | |
bounce:function(pos){if(pos<(1/2.75)){return(7.5625*pos*pos)}else{if(pos<(2/2.75)){return(7.5625*(pos-=(1.5/2.75))*pos+0.75)}else{if(pos<(2.5/2.75)){return(7.5625*(pos-=(2.25/2.75))*pos+0.9375)}else{return(7.5625*(pos-=(2.625/2.75))*pos+0.984375)}}}}, | |
bouncePast:function(pos){if(pos<(1/2.75)){return(7.5625*pos*pos)}else{if(pos<(2/2.75)){return 2-(7.5625*(pos-=(1.5/2.75))*pos+0.75)}else{if(pos<(2.5/2.75)){return 2-(7.5625*(pos-=(2.25/2.75))*pos+0.9375)}else{return 2-(7.5625*(pos-=(2.625/2.75))*pos+0.984375)}}}}, | |
easeFromTo:function(pos){if((pos/=0.5)<1){return 0.5*Math.pow(pos,4)}return -0.5*((pos-=2)*Math.pow(pos,3)-2)}, | |
easeFrom:function(pos){return Math.pow(pos,4)}, | |
easeTo:function(pos){return Math.pow(pos,0.25)} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome. thank you so much.