My sprite animation works perfectly on the odd clicks (1, 3, 5 . .) which puts the switch in the down position, but I can't get the even clicks(2, 4, 6. . .) to fire the animation that puts the switch in the up position. Cross browser CSS removed from the post but is in the Fiddle.
HTML
<div class="switch s-up"></div>
jQuery
$(document).ready(function() {
$(".switch").click(function () {
$(this).toggleClass("s-down s-up");
});
})
CSS
.switch{
background: transparent url(http://i.imgur.com/taIR0.jpg);
height:65px;
width: 75px;
margin-bottom:75px;
cursor:pointer;
}
.s-down{
animation: play .4s steps(5);
}
.s-up{
animation: reverse .4s steps(5);
}
.switch.s-down{
background: transparent url(http://i.imgur.com/taIR0.jpg) -300px 0;
}
@keyframes play {
0% { background-position: 0px; }
100% { background-position: -375px; }
}
@keyframes reverse {
0% { background-position: -375px; }
100% { background-position: 0px; }
}