Skip to content

Instantly share code, notes, and snippets.

@spite
Created May 6, 2016 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spite/c202687a62dd2466b5828f410f3b887c to your computer and use it in GitHub Desktop.
Save spite/c202687a62dd2466b5828f410f3b887c to your computer and use it in GitHub Desktop.
// 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