简体   繁体   English

在MS Edge中操纵负动画延迟值

[英]Manipulate negative animation-delay value in MS Edge

I try using the animation-delay with negative values. 我尝试使用带有负值的animation-delay。 The value should be manipulated with JavaScript to control the animation. 该值应使用JavaScript进行控制,以控制动画。 The following pen works in all modern browsers, but not in MS Edge. 以下笔可在所有现代浏览器中使用,但不适用于MS Edge。 Also not with the corresponding vendor prefixes. 也不要使用相应的供应商前缀。

Codepen Example Codepen示例

 function change(val){ var box = document.getElementById('box'); box.style.animationDelay = -val + 's'; } 
 #box { width: 200px; height: 200px; background-color: red; animation-name: effect; animation-duration: 1s; animation-delay: 0s; -webkit-animation-play-state: paused; -moz-animation-play-state: paused; -ms-animation-play-state: paused; -o-animation-play-state: paused; animation-play-state: paused; -webkit-animation-fill-mode: forwards; -moz-animation-fill-mode: forwards; -ms-animation-fill-mode: forwards; -o-animation-fill-mode: forwards; animation-fill-mode: forwards; } input { margin-top: 10px; width: 200px; } @-webkit-keyframes effect { to { background-color: blue; } } @-moz-keyframes effect { to { background-color: blue; } } @-ms-keyframes effect { to { background-color: blue; } } @keyframes effect { to { background-color: blue; } } 
 <div id="box" class="transitionEffect"></div> <input type="range" id="range" min="0" max="1" step="0.05" value="0" oninput="change(this.value)"> 

Isn't this supported by MS Edge? MS Edge不支持吗?

This bug report on MS shows the problem: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7729819/ 关于MS的此错误报告显示了该问题: https : //developer.microsoft.com/zh-cn/microsoft-edge/platform/issues/7729819/

You cannot change animation related values with an effect in Edge. 您无法在Edge中使用效果更改与动画相关的值。 It seems that Edge adhers to an older draft specification of CSS animation which tells that; Edge似乎遵循了CSS动画的较早的规范草案,该规范说明了这一点。

The values used for the keyframes and animation properties are snapshotted at the time the animation starts. 动画开始时会快照用于关键帧和动画属性的值。 Changing them during the execution of the animation has no effect. 在动画执行期间更改它们无效。

From https://www.w3.org/TR/2013/WD-css3-animations-20130219/#animations https://www.w3.org/TR/2013/WD-css3-animations-20130219/#animations

But you have one chance, if you change the animation-name property to a different value the animation starts anew and you can simultaneously change the other animation properties. 但是您有机会,如果将animation-name属性更改为其他值,则动画将重新开始,并且您可以同时更改其他动画属性。 This has to be done repeatedly every time you want to change an animation property. 每次要更改动画属性时,都必须重复执行此操作。 You can of course toggle between animations with identical keyframes definitions but only different names. 当然,您可以在具有相同关键帧定义但只有不同名称的动画之间切换。

Great, i rebuilt the pen and toggle the animation when using the MS Edge. 太好了,在使用MS Edge时,我重建了笔并切换了动画。 The performance goes down a bit, but MS Edge users don't know it differently anyway. 性能略有下降,但是MS Edge用户对此并不陌生。 :) :)

You should make sure that the step is deeper than 1 to get a smoother animation. 您应该确保该步长大于1,以使动画更流畅。

Thanks for your help! 谢谢你的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM