mozilla

Revision 22088 of animation-timing-function

  • Revision slug: CSS/animation-timing-function
  • Revision title: animation-timing-function
  • Revision id: 22088
  • Created:
  • Creator: myakura
  • Is current revision? No
  • Comment 56 words added, 34 words removed

Revision Content

{{ CSSRef() }}

{{ draft() }}

Summary

The animation-timing-function property specifies how a CSS animation should progress over the duration of each cycle. The possible values are the same as those used by the {{ cssxref("transition-timing-function") }} property for CSS transitions.

For keyframed animations, the timing function applies between keyframes rather than over the entire animation. In other words, the timing function is applied at the start of the keyframe and at the end of the keyframe.

An animation timing function defined within a keyframe block applies to that keyframe; otherwise. If no timing function is specified for the keyframe, the fiming function specified for the overall animation is used.

It is often convenient to use the shorthand property {{ cssxref("animation") }} to set all animation properties at once.

  • {{ xref_cssinitial() }}: ease
  • Applies to: block-level and inline-level elements
  • {{ xref_cssinherited() }}: no
  • Media: {{ xref_cssvisual() }}
  • {{ xref_csscomputed() }}: as specified

Syntax

animation-timing-function: ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>)[,
                           ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>)]*

Values

ease
This keyword sets the easing function to cubic-bezier(0.25, 0.1, 0.25, 1.0).
linear
This keyword sets the easing function to cubic-bezier(0.0, 0.0, 1.0, 1.0).
ease-in
This keyword sets the easing function to cubic-bezier(0.42, 0.0, 1.0, 1.0).
ease-out
This keyword sets the easing function to cubic-bezier(0.0, 0.0, 0.58, 1.0).
ease-in-out
This keyword sets the easing function to cubic-bezier(0.42, 0.0, 0.58, 1.0).
cubic-bezier
Specifies a cubic bezier curve to use as the easing function. The four number values specify the P1 and P2 points of the curve as (x1, y1, x2, y2). All values must be in the range [0.0, 1.0] inclusive.

Examples

See CSS animations for examples.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }} {{ CompatGeckoDesktop("5.0") }}{{ property_prefix("-moz") }} {{ CompatUnknown() }} {{ CompatUnknown() }} 4.0{{ property_prefix("-webkit") }}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

Specifications

  • {{ spec("http://www.w3.org/TR/css3-animations/#the-animation-timing-function-property-", "CSS Animations Module Level 3: animation-timing-function", "WD") }}

See also

  • CSS animations
  • {{ domxref("Event/AnimationEvent", "AnimationEvent") }}
  • {{ CSS_Reference:animation() }}

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ draft() }}</p>
<h2>Summary</h2>
<p>The <code>animation-timing-function</code> property specifies how a CSS animation should progress over the duration of each cycle. The possible values are the same as those used by the {{ cssxref("transition-timing-function") }} property for <a href="/en/CSS/CSS_transitions">CSS transitions</a>.</p>
<p>For keyframed animations, the timing function applies between keyframes rather than over the entire animation. In other words, the timing function is applied at the start of the keyframe and at the end of the keyframe.</p>
<p>An animation timing function defined within a keyframe block applies to that keyframe; otherwise. If no timing function is specified for the keyframe, the fiming function specified for the overall animation is used.</p>
<p>It is often convenient to use the shorthand property {{ cssxref("animation") }} to set all animation properties at once.</p>
<ul> <li>{{ xref_cssinitial() }}: ease</li> <li>Applies to: block-level and inline-level elements</li> <li>{{ xref_cssinherited() }}: no</li> <li>Media: {{ xref_cssvisual() }}</li> <li>{{ xref_csscomputed() }}: as specified</li>
</ul>
<h2>Syntax</h2>
<pre>animation-timing-function: ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;, &lt;number&gt;)[,
                           ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(&lt;number&gt;, &lt;number&gt;, &lt;number&gt;, &lt;number&gt;)]*
</pre>
<h3>Values</h3>
<dl> <dt>ease</dt> <dd>This keyword sets the easing function to <code>cubic-bezier(0.25, 0.1, 0.25, 1.0)</code>.</dd> <dt>linear</dt> <dd>This keyword sets the easing function to <code>cubic-bezier(0.0, 0.0, 1.0, 1.0)</code>.</dd> <dt>ease-in</dt> <dd>This keyword sets the easing function to <code>cubic-bezier(0.42, 0.0, 1.0, 1.0)</code>.</dd> <dt>ease-out</dt> <dd>This keyword sets the easing function to <code>cubic-bezier(0.0, 0.0, 0.58, 1.0)</code>.</dd> <dt>ease-in-out</dt> <dd>This keyword sets the easing function to <code>cubic-bezier(0.42, 0.0, 0.58, 1.0)</code>.</dd> <dt>cubic-bezier</dt> <dd>Specifies a cubic bezier curve to use as the easing function. The four number values specify the P<sub>1</sub> and P<sub>2</sub> points of the curve as (x<sub>1</sub>, y<sub>1</sub>, x<sub>2</sub>, y<sub>2</sub>). All values must be in the range [0.0, 1.0] inclusive.</dd>
</dl>
<h2>Examples</h2>
<p>See <a href="/en/CSS/CSS_animations">CSS animations</a> for examples.</p>
<h2 name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }}</td> <td>{{ CompatGeckoDesktop("5.0") }}{{ property_prefix("-moz") }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>4.0{{ property_prefix("-webkit") }}</td> </tr> </tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody>
</table>
</div>
<h2>Specifications</h2>
<ul> <li>{{ spec("http://www.w3.org/TR/css3-animations/#the-animation-timing-function-property-", "CSS Animations Module Level 3: animation-timing-function", "WD") }}</li>
</ul>
<h2>See also</h2>
<ul> <li><a href="/en/CSS/CSS_animations">CSS animations</a></li> <li>{{ domxref("Event/AnimationEvent", "AnimationEvent") }}</li> <li>{{ CSS_Reference:animation() }}</li>
</ul>
Revert to this revision