这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
EffectTiming
dictionary's
easing
property in the
Web 动画 API
specifies the timing function used to scale the time to produce easing effects, where
easing
is the rate of the animation's change over time.
Element.animate()
,
KeyframeEffectReadOnly()
,和
KeyframeEffect()
all accept an object of timing properties including
easing
. The value of easing corresponds directly to
AnimationEffectTimingReadOnly.easing
in
timing
objects returned by
AnimationEffectReadOnly
,
KeyframeEffectReadOnly
,和
KeyframeEffect
.
var timingProperties = {
easing: single-transition-timing-function
}
timingProperties.easing = single-transition-timing-function
A string defining the timing function to use for easing transitions during the animation process. Accepts several pre-defined
DOMString
values, a
steps()
timing function like
steps(5, end)
, or a custom
cubic-bezier
value like
cubic-bezier(0.42, 0, 0.58, 1)
。默认为
linear
. Available values include:
linear
A constant rate of change, neither accelerating nor deccelerating.
cubic-bezier(<number>, <number>, <number>, <number>)
ease
cubic-bezier(0.25, 0.1, 0.25, 1)
.
ease-in
cubic-bezier(0.42, 0, 1, 1)
.
ease-out
cubic-bezier(0, 0, 0.58, 1)
.
ease-in-out
cubic-bezier(0.42, 0, 0.58, 1)
.
frames(<integer>)
steps()
and
frames()
.
steps(<integer>[, [ start | end ] ]?)
step-start
steps(1, start)
step-end
steps(1, end)
.
在
Red Queen's Race
example, we animate Alice and the Red Queen by passing an easing
of steps(7, end)
to
animate()
:
// Define the key frames
var spriteFrames = [
{ transform: 'translateY(0)' },
{ transform: 'translateY(-100%)' }
];
// Get the element that represents Alice and the Red Queen
var redQueen_alice_sprite = document.getElementById('red-queen_and_alice_sprite');
// Animate Alice and the Red Queen using steps()
var redQueen_alice = redQueen_alice_sprite.animate(
spriteFrames, {
easing: 'steps(7, end)',
direction: "reverse",
duration: 600,
playbackRate: 1,
iterations: Infinity
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web 动画
The definition of 'easing' in that specification. |
工作草案 | 编者草案。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
easing
|
Chrome 52 | Edge ≤79 | Firefox 63 | IE No | Opera Yes | Safari No | WebView Android 52 | Chrome Android 52 | Firefox Android 63 | Opera Android Yes | Safari iOS No | Samsung Internet Android Yes |
jump-
keywords for
steps()
|
Chrome 52 | Edge ≤79 | Firefox 65 | IE No | Opera No | Safari No | WebView Android 52 | Chrome Android 52 | Firefox Android 65 | Opera Android 55 | Safari iOS No | Samsung Internet Android 12.0 |
完整支持
不支持
实验。期望将来行为有所改变。
Element.animate()
,
KeyframeEffect()
,和
AnimationEffect.updateTiming()
all accept an object of timing properties including this one.
EffectTiming
(which is returned from
AnimationEffect.getTiming()
and
AnimationEffect.getComputedTiming()
).
animation-timing-function
and
transition-timing-function
.