Read below for my final edit!
Is it possible to use CSS3 animation without animation between frames?
For example, I have an image in which there are two sprites characters. They are evenly spaced at 50 pixels. When I use the following animation, I still get the animation (although the animation is very fast, so it may look like a flicker).
#ball .animated{ -webkit-animation-name: animate; -webkit-animation-duration: .5s; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; -webkit-animation-timing-function: linear;} @-webkit-keyframes animate{ 0%{-webkit-transform: translate3d(0,0,0);} 49%{-webkit-transform: translate3d(0,0,0);} 50%{-webkit-transform: translate3d(-50px,0,0);} 100%{-webkit-transform: translate3d(-50px,0,0);}
So, based on the foregoing, the sprite frame should be held on the first part of the image (x = 0px) for the first 0-49% of the duration, and then go to the second part of the image (x = -50px) for 50-100%. However, 1% of the difference is still enough to visually see animations from 0 to -50px.
Thoughts?
Edit:
-webkit-animation-timing-function: cubic-bezier(1,0,1,0);
The above seemed to straighten up a bit, but after a while it returned to flicker.
Edit: I did not understand that you can use decimal numbers with percentages. Closing a space from 1% to 0.1% creates a much faster animation that is almost -webkit-animation-duration: (with -webkit-animation-duration: <1s;)
0%{-webkit-transform: translate3d(0,0,0);} 49.9%{-webkit-transform: translate3d(0,0,0);} 50%{-webkit-transform: translate3d(-50px,0,0);} 100%{-webkit-transform: translate3d(-50px,0,0);}
Final editing !: So, from what I found, the percentages of the web set animation will take a decimal number in a millionth place (i.e. 0.0001). Which with a relatively fast animation timer will result in instant translation. I guess a little hack, but this is a trick.
Example:
@-webkit-keyframes sprite { 0% { -webkit-transform: translate3d(0,0,0); } 50% { -webkit-transform: translate3d(0,0,0); } 50.0001%{ -webkit-transform: translate3d(-50px,0,0); } 100%{ -webkit-transform: translate3d(-50px,0,0); } }
The above example has a 100px image (each sprite in an image with a width of 50 pixels) inside the container div with width: 50px and overflow:hidden to display only one sprite from the image at a time.
Note. I use translate3d because it is hardware accelerated in mobile browsers where translateX, translateY, translateZ are not yet hardware accelerated.