Animate API

Tags
webapi
Created
Nov 6, 2015 12:38 PM

Top Layer Animationshttps://developer.chrome.com/blog/entry-exit-animations/

支持伪元素:https://developer.mozilla.org/en-US/docs/Web/API/CSSPseudoElement

支持合成:https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/composite

element.animate({变化的CSS属性(侦)数组},{控制选项})

参数前者叫KeyframeEffects,时间偏移用offset属性

后者叫AnimationEffectTimingProperties

animate()返回一个AnimationPlayer对象,并执行动画

最大的好处是可以使用变量

AnimationPlayer可以暂停,播放,结束

创建的默认时间轴document.timeline

getAnimations()返回所以动画(running/pause)引用包括CSS

var effect = new KeyframeEffect(elem, keyframes, timings);//定义动画

document.timeline.play(KeyframeEffect/GroupEffect一起播放/SequenceEffect一个播放完接下一个),返回一个动画(组)对象

通过playState属性读取动画的状态,通过如play()、pause()、和finish()这样的方法来改变动画的状态。我们还可以通过读/写playbackRate属性来改变播放速度,变快变慢都可以。currentTime可以也可以读/写,我们还可以通过onfinish在动画结束时设置一个回调。

Firefox 使用new Animation()

element.style.motionPath

motion-rotation

motion-offset

规范已经发展到引入一个ready Promise

SuperMade with Super