javascript - Stop a CSS rotate animation smoothly -


i created sample css class roate image indefinitely :

.rotate{     animation: rotation 2s infinite linear; }  @keyframes rotation {     {         transform: rotate(0deg);     }     {         transform: rotate(359deg);     } } 

i add class image in html page. shortly after want stop rotation smoothly unknown keyframe. must create css class :

.rotatetostop{     ... } 

and javascript code :

$('myelement').addclass('rotate'); // ...  // shortly after, when specific event triggered $('myelement').removeclass('rotate'); $('myelement').addclass('rotatetostop'); 

but haven't ideas how in css 'rotatetostop' class , can me ? =)

i'm afraid can't stop animation smoothly if remove animation element removing class.

but can stop animation using this:

.rotatetostop {   animation-play-state: paused;  } 

in case shouldn't remove .rotate class have toggle class starts or pauses animation.

one problem: animation freeze @ moment add needed class.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -