Skip to content

Instantly share code, notes, and snippets.

@TheSavior
Last active August 29, 2015 14:21
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 TheSavior/c8dcc7fa886ebf3a6d45 to your computer and use it in GitHub Desktop.
Save TheSavior/c8dcc7fa886ebf3a6d45 to your computer and use it in GitHub Desktop.
Wealthfront Blog Embed jQuery Deconstructed Example
var element = document.getElementsByClassName('selector')[0];
var current = element.style.top;
var goal = 100;
var duration = 2;
var step = (goal - current) / (duration * 60);
var tick = function() {
current += step;
element.style.top = current + 'px';
if (current < goal) {
setTimeout(tick, 1000/60);
}
}
tick();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment