I’ve been working wtih CSS3 animations lately, primarily to add motion and excitement to my project. I’ve played around with them and I’ve figured out the basics with entrances, exits, transitions, scaling, etc. The method that I’ve been doing is essentially using a state as a boolean. If a button is clicked, the state is toggled and the animation class is added onto the div container. It looks something like this (most of this code is courtesy of Seimith Suth):
The problem with this, is that the button simply toggles between true false. There is no ellegant way to set the state back to false after the animation is done. However, there are some alternatives:
In my opinion, the easier solution would be simply to use a setTimeout function to automatically run a function that sets the state as false after a given amount of time. SImply set the interval to be equal to or longer than the animation and it should work. Simple!
The second way is to use jQuery. I’m no expert on jQuery so I’ll let Google do the work for me. I know a lot of people were posting about it so I figured there is a solution.
Hope this helped!