简体   繁体   English

CSS3动画“进度”回调

[英]CSS3 animation “progress” callback

I just wanted to know if there is a way to monitor progress of a element's animation. 我只是想知道是否有一种方法可以监视元素动画的进度。 All I know is animationstart and animationend , Is there some sort of animationprogress ? 我所知道的只是animationstartanimationend ,是否存在某种animationprogress

No, there is no animationprogess event. 不,没有animationprogess事件。 Per the W3 specification , there are three types of AnimationEvent events. 根据W3规范 ,存在三种类型的AnimationEvent事件。 There is animationstart , animationend and animationiteration . animationstartanimationendanimationiteration animationiteration is fired in place of animationend when the animation is about to repeat again. 当动画要再次重复播放时,会触发animationiteration代替animationend

You could presumably use a setInterval() that was set for some fraction of the animation time (eg 10% of the animation time) and then you would get called at each point in the animation. 您大概可以使用setInterval()设置为动画时间的一小部分(例如动画时间的10%),然后在动画的每个点都会被调用。 You could query the progress of the animation at any of those timer events if you needed a precise position of the animation. 如果需要精确定位动画,则可以在任何这些计时器事件中查询动画的进度。

Or, if you wanted more precision of timing, you could break your animation up into multiple sequential animations and use animationend on each piece as your progress indicator and the trigger to start the next phase of the animation. 或者,如果您想要更精确的定时,则可以将动画分解为多个连续动画,并在每个片段上使用animationend作为进度指示器和触发以开始下一阶段动画的触发器。

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

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