Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 animation reset

I have a question about CSS3. Is there an option to reset the animation after it finish (for example by using jQuery)?

Example: after button click, animation reset.

like image 367
Amay Avatar asked Oct 02 '12 14:10

Amay


People also ask

How do you reset an animation in CSS?

The key to restarting a CSS animation is to set the animation-name of an animation to 'none' and then setting it back to the original animation. As you can see this requires two steps. One to switch it to a different animation and one to set it back.

How do you repeat an animation in CSS?

The animation-iteration-count property in CSS is used to specify the number of times the animation will be repeated. It can specify as infinite to repeat the animation indefinitely.

Can you pause CSS animation?

The only way to truly pause an animation in CSS is to use the animation-play-state property with a paused value. In JavaScript, the property is “camelCased” as animationPlayState and set like this: element. style.

What is animation fill mode in CSS?

The animation-fill-mode property specifies a style for the element when the animation is not playing (before it starts, after it ends, or both). CSS animations do not affect the element before the first keyframe is played or after the last keyframe is played. The animation-fill-mode property can override this behavior.


1 Answers

I found better solution:

$('something').removeClass('anim').animate({'nothing':null}, 1, function () {
$(this).addClass('anim');
});

It's working. Ofc it need a css class '.anim' with the animation.

like image 53
Amay Avatar answered Oct 24 '22 12:10

Amay