Skip to content

Instantly share code, notes, and snippets.

@joeydi
Last active August 29, 2015 13:56
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 joeydi/9137384 to your computer and use it in GitHub Desktop.
Save joeydi/9137384 to your computer and use it in GitHub Desktop.
Animation with javscript and a vertical sprite of animation frames.
Today.page_turn_forward = function () {
var y = 322,
i = 0,
frame_count = 27,
frame = $('.anim-frame'),
interval;
frame.show()
// Start position
frame.css('background-position', '0 ' + (y * frame_count * -1) + 'px');
interval = setInterval(function() {
i++;
frame.css('background-position', '0 ' + (y * (frame_count - i) * -1) + 'px');
if ( i == frame_count ) {
clearInterval(interval);
frame.hide();
}
}, 1000/30);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment