我已经实现了动画暂停,如下所述: How to patrick andresume CSS3animation using JavaScript?
这是我的旋转元素的 CSS:
.is-rotating{
-webkit-animation: circle 55s linear infinite;
-moz-animation: circle 55s linear infinite;
-ms-animation: circle 55s linear infinite;
animation: circle 55s linear infinite;
}
Run Code Online (Sandbox Code Playgroud)
我将一个is-paused类切换到有问题的元素onmouseover:
.is-paused{
-webkit-animation-play-state:paused;
-moz-animation-play-state:paused;
-o-animation-play-state:paused;
animation-play-state:paused;
}
Run Code Online (Sandbox Code Playgroud)
当我用 JS (onmouseout) 删除此类时,旋转动画重置为“原点”。有时会,有时不会。这种情况发生在 webkit(OSX 上的 Chrome 和 Safari)中,在 FF 中工作正常。
我知道animation-play-state这是一个实验性功能,但MDN 说它在 webkit 中应该可以正常工作。有谁对如何实现 webkit 浏览器有任何想法吗?
更新:这是 CSS 的其余部分:
@-webkit-keyframes circle {
from { -webkit-transform:rotate(0deg); }
to { -webkit-transform:rotate(360deg); }
} …Run Code Online (Sandbox Code Playgroud)