I have an object that has an animation when the page is loaded:
.logo-mark {
-webkit-animation: spin 2s 1 cubic-bezier(0.000, 0.000, 0.230, 1.000);
-moz-animation: spin 2s 1 cubic-bezier(0.000, 0.000, 0.230, 1.000);
-ms-animation: spin 2s 1 cubic-bezier(0.000, 0.000, 0.230, 1.000);
animation: spin 2s 1 cubic-bezier(0.000, 0.000, 0.230, 1.000);
}
At a certain time, I want JavaScript to turn on a specific animation that occurs endlessly, until JavaScript stops said animation. So I simply made another class named .logo-loading, and at certain times, jQuery does an addClass and a removeClass.
.logo-loading {
-webkit-animation: spin 4s infinite linear;
-moz-animation: spin 4s infinite linear;
-ms-animation: spin 4s infinite linear;
animation: spin 4s infinite linear;
}
However, when JavaScript removes the class, the object just keeps rotating no matter what. Is there anything I can do here?
Why do we usually add the stop() method before calling animate() ? stop() halts the execution of the scripts on the page until the animation has finished. stop() ends any currently running animations on the element, and prevents conflicts and pile-ups. We tell jQuery that the animation has to be stopped at some point.
To remove more than one animation effect from text or an object, in the Animation Pane, press Ctrl, click each animation effect that you want to remove, and then press Delete. To remove all animation effects from text or an object, click the object that you want to stop animating.
You can just override that CSS properties with "none" to every animation
function stopAnimation(element)
{
$(element).css("-webkit-animation", "none");
$(element).css("-moz-animation", "none");
$(element).css("-ms-animation", "none");
$(element).css("animation", "none");
}
so you can stop animation simply calling this function...
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