我有一个延迟的CSS动画,我在延迟期间暂停它。 它在Firefox和Chrome上按预期工作,“Hello”不会移动。 但是在Safari上,动画跳转到最后一帧。 为什么以及如何修复?在Safari中的CSS动画错误
function test() {
var timeout = 1000;
setTimeout(function() {
document.getElementById('animation').style.animationPlayState = 'paused';
}, timeout);
}
document.addEventListener("DOMContentLoaded", test);
#animation {
animation: test 2s linear 2s;
}
@keyframes test {
to {
transform: translateY(100px);
}
}
<div id="animation">
Hello (this text should not move)
</div>
如果我删除了2秒延时,设置持续时间4秒,并添加关键帧与变换:没有,我可以让这个简单的例子工作。不过,我真实的情况下有多个动画,与延迟同步。
无法重现。在Safari 11.0(macOS)中,它按预期工作。 – Styx
@Styx我刚刚在Safari 11.0中测试过,错误仍然存在。 “你好”跳到底部而不是暂停。 – Patrick
请尝试这个jsfiddle,请:https://jsfiddle.net/iStyx/2uqf1p9y/ – Styx