I'm targeting older webkit browser QT Webkit, which unfortunately doesn't support changing background image in the keyframes. So intead, I've created sprite combining all 12 frames and now am trying to go through each frame with some interval to create animation. But I have a horizontal sprite and when I try to changing background-position-x
at some keyframe %, it slides.
Sprite: http://i.imgur.com/krQPw.png
Sample: http://jsbin.com/amoxef/1 (I set the animation duration longer to see what's happening. Originally I would like it to be set to 1 second for the full animation cycle).
How do I make it so that it will "jump" instead of sliding to the next frame (location in sprite)?
Finally got it: http://jsbin.com/amoxef/6
I made it so that it will stay the same location from for example 0% to 7.999% and at 8%, it will change the
background-position
. So, since the actual changing period is so small, it looks like it "jumps" to the next frame and stays on it until the next defined % frame.You should check out the
steps()
option in CSS keyframes.Here is an example that I haven't tested... just a demo of using
steps()
... More details here: Taking steps() with CSS animations.