Last active
August 29, 2015 13:56
-
-
Save joeydi/9137384 to your computer and use it in GitHub Desktop.
Animation with javscript and a vertical sprite of animation frames.
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
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