I created a rotation animation in css that takes 1s and has 'forwards' set with a class .comet . How can i have that animation start at every click on an exterior element?
#carousel #big_bubble #cometa.rotation{animation:rotation 1s forwards; -moz-animation:rotation 1.5s forwards; -webkit-animation:rotation 1s forwards; -o-animation:rotation forwards 1s; }
@-moz-keyframes rotation{
from{transform:rotate(0deg);}
to{transform:rotate(-360deg);}
@-webkit-keyframes rotation{
from{-webkit-transform:rotate(0deg);}
to{-webkit-transform:rotate(-360deg);}
}
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.
On the Animations tab, in the Advanced Animation group, click Animation Pane. In the Animation Pane, select the animation that you want to trigger. In the Advanced Animation group, click Trigger, point to On Click of, and select the object that you want to trigger the animation.
The animation-play-state CSS property sets whether an animation is running or paused.
The animate() is an inbuilt method in jQuery which is used to change the state of the element with CSS style. This method can also be used to change the CSS property to create the animated effect for the selected element. Syntax: (selector).
$(function() {// Shorthand for $( document ).ready()
$( ".trigger" ).click(function(e) {
e.preventDefault();
$(this).addClass( "animation" ).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){
$(this).removeClass( "animation" );
});
});
});
Resources:
Not sure I understand you right. Anyway:
$('#button').click(function() {
var el = $('#cometa').addClass('rotation');
setTimeout(function() {
el.removeClass('rotation');
}, 1000);
});
http://jsfiddle.net/EPv3B/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With