This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The {domxref("AnimationEffectTimingProperties")}} dictionary's easing
property in the Web Animations 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()
, and 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
, and 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)
. Defaults to linear
. Available values include:
linear
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)
.steps(<integer>[, [ start | end ] ]?)
step-start
steps(1, start)
step-end
steps(1, end)
.In the 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 });
Specification | Status | Comment |
---|---|---|
Web Animations The definition of 'easing' in that specification. | Working Draft | Editor's draft. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) | 48 (48)[1] | No support | (Yes) | No support |
Feature | Android | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | ? | ? | ? | 48.0 (48)[1] | ? | No support | No support | No support |
[1] The Web Animations API is only enabled by default in Firefox Developer Edition and Nightly builds. You can enable it in beta and release builds by setting the preference dom.animations-api.core.enabled
to true
, and can disable it in any Firefox version by setting this preference to false
.
Element.animate()
, KeyframeEffectReadOnly()
, and KeyframeEffect()
all accept an object of timing properties including this one.AnimationEffectTimingReadOnly
(which is the timing
object for AnimationEffectReadOnly
, KeyframeEffectReadOnly
, and KeyframeEffect
).animation-timing-function
and transition-timing-function
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AnimationEffectTimingProperties/easing