Created
May 6, 2016 08:43
-
-
Save spite/c202687a62dd2466b5828f410f3b887c to your computer and use it in GitHub Desktop.
This file contains 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
// if an invalidate mechanism is in place | |
// easings based on expressions might have | |
// a bit of zeno's paradox, in which the | |
// value infinitesimally converges to the | |
// target value | |
var value = 0; | |
var nValue = 1; | |
function animate() { | |
requestAnimationFrame( animate ); | |
// easing | |
value += ( nValue - value ) * .1; | |
// epsilon check | |
var epsilon = .001; // can be adjusted, depends on what the value is used for | |
if( Math.abs( nValue - value ) < epsilon ) { | |
value = nValue; | |
} else { | |
// draw() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment