jquery - How to Pause ALL CSS animations? -
how go pausing css animations in document @ start? want have class on elements contain css animations @ start, ie: '.paused'. then, using call in js using jquery, remove class '.paused', add class resume playing, ie: '.running'.
here i've got:
html:
<li class="firstanimation paused">...</li> <li class="secondanimation paused">...</li> <li class="thirdanimation paused">...</li> css:
#slider li.paused { -webkit-animation-play-state: paused; -moz-animation-play-state: paused; -ms-animation-play-state: paused; -o-animation-play-state: paused; animation-play-state: paused; } #slider li.firstanimation { animation: cycle 25s linear infinite;-moz-animation:cycle 25s linear infinite;-webkit-animation:cycle 25s linear infinite; } #slider li.secondanimation { animation: cycletwo 25s linear infinite;-moz-animation:cycletwo 25s linear infinite;-webkit-animation:cycletwo 25s linear infinite; } #slider li.thirdanimation { animation: cyclethree 25s linear infinite;-moz-animation:cyclethree 25s linear infinite;-webkit-animation:cyclethree 25s linear infinite; } so, problem "#slider li.paused" selector doesn't work. in chrome, inspector says 'animation-play-state:paused;' invalid property value...? dont because have in css , works fine:
#slider:hover li, #slider:hover .progress-bar { -webkit-animation-play-state: paused; -moz-animation-play-state: paused; -ms-animation-play-state: paused; -o-animation-play-state: paused; animation-play-state: paused; } so again, in nutshell, how target animations class have them paused? according w3 docs, animation-play-state: paused; "applies to: elements, ::before , ::after pseudo-elements." doesnt in case. have wrong?
your appreciated.
thnx!
your problem due selector specificity. since both .paused , li.elemclass have same specificity, compiler choose last one
to fix can move .paused properties after others or make have more precedence adding layer, body #slider li.paused
check docs more info on specificity , here's specificity calculator convenience
Comments
Post a Comment