{"id":21743,"date":"2015-02-03T12:35:59","date_gmt":"2015-02-03T11:35:59","guid":{"rendered":"http:\/\/tympanus.net\/codrops\/?post_type=css_reference&#038;p=21743"},"modified":"2016-12-11T21:45:04","modified_gmt":"2016-12-11T20:45:04","slug":"animation-timing-function","status":"publish","type":"css_reference","link":"https:\/\/tympanus.net\/codrops\/css_reference\/animation-timing-function\/","title":{"rendered":"animation-timing-function"},"content":{"rendered":"<div class=\"ct-cssref-description\">\n<p>\n                    The <code class=\"\" data-line=\"\">animation-timing-function<\/code> property is used to specify a <em>timing function<\/em> which defines the speed over time of an object being animated. It describes how an <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/animation\">animation<\/a> will progress over one cycle of its duration, allowing it to change speed during its course.\n                <\/p>\n<p>\n                    A timing function in CSS is usually referred to <em>easing functions<\/em>.\n                <\/p>\n<p>\n                    The <code class=\"\" data-line=\"\">animation-timing-function<\/code> takes a timing function as a value, which is a mathematical function that specifies the speed over time of an object being animated. It can also be defined using one of several predefined keywords for common timing functions.\n                <\/p>\n<p>\n                    If you apply more than one <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/animation\">animation<\/a> on an element, you may specify multiple timing functions, each for a corresponding animation specified using the <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/animation-name\">animation-name<\/a> property.\n                <\/p>\n<p>\n                    The timing function specified applies <strong>to each iteration of the animation, not the entire animation<\/strong> in full. For example, if an animation has <code class=\"\" data-line=\"\">animation-timing-function: ease-in-out;<\/code> and <code class=\"\" data-line=\"\">&lt;a href=&quot;http:\/\/tympanus.net\/codrops\/css_reference\/animation-iteration-count&quot;&gt;animation-iteration-count&lt;\/a&gt;: 2;<\/code>, it will ease in at the start, ease out as it approaches the end of its first iteration, ease in at the start of its second iteration, and ease out again as it approaches the end of the animation.\n                <\/p>\n<p>\n                    <strong>For keyframed animations, the timing function applies between keyframes rather than over the entire animation<\/strong>. In other words, the timing function is applied at the start of a keyframe and at the end of a keyframe.\n                <\/p>\n<p>\n                    In addition to being able to specify a timing function for an overall animation, you can specify an animation timing function for an individual keyframe of the animation inside the keyframe rule that is used to animate the element in that keyframe as it proceeds to the next keyframe (See the Examples section below for an example). If no timing function is specified for the keyframe, the timing function specified for the overall animation is used. You can read more about this and see an example in the <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/keyframes_rule\"><code class=\"\" data-line=\"\">@keyframes<\/code><\/a> entry.\n                <\/p>\n<p>\n                    It is usually more convenient to specify the <code class=\"\" data-line=\"\">animation-timing-function<\/code> in the <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/animation\"><code class=\"\" data-line=\"\">animation<\/code><\/a> shorthand property.\n                <\/p>\n<\/p><\/div>\n<div class=\"ct-cssref-info\">\n<h2>Official Syntax<\/h2>\n<ul>\n<li>\n                       <strong>Syntax: <\/strong> animation-timing-function: <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/timing-function\"><code class=\"\" data-line=\"\">&lt;timing-function&gt;<\/code><\/a>\n                    <\/li>\n<li>\n                        <strong>Initial: <\/strong> ease\n                    <\/li>\n<li>\n                       <strong>Applies To: <\/strong> all elements; and <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/before\"><code class=\"\" data-line=\"\">::before<\/code><\/a> and <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/after\"><code class=\"\" data-line=\"\">::after<\/code><\/a> pseudo-elements\n                    <\/li>\n<li>\n                        <strong>Animatable: <\/strong> no\n                    <\/li>\n<\/ul><\/div>\n<div class=\"ct-cssref-values\">\n<h2>Values<\/h2>\n<dl>\n<dt>&lt;timing-function&gt;<\/dt>\n<dd>\n                        See the <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/timing-function\"><code class=\"\" data-line=\"\">&lt;timing-function&gt;<\/code><\/a> entry for a list of possible values, detailed explanation of each, and examples and demos for each value.\n                    <\/dd>\n<\/p><\/div>\n<div class=\"ct-cssref-examples\">\n<h2>Examples<\/h2>\n<p>\n                    The following example applies an <code class=\"\" data-line=\"\">animation-timing-function<\/code> to an animation applied to two animations applied to an element:\n                <\/p>\n<pre class=\"brush:css\">\r\n.element {\r\n    animation-name: rotate, fall;\r\n    animation-timing-function: ease-in, ease-in-out;\r\n}\r\n                <\/pre>\n<p>\n                    The following example applies an <code class=\"\" data-line=\"\">animation-timing-function<\/code> to individual keyframes inside a <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/keyframes_rule\"><code class=\"\" data-line=\"\">@keyframes<\/code><\/a> rule:\n                <\/p>\n<pre class=\"brush:css\">\r\n@keyframes bounce {\r\n\r\n  from {\r\n    top: 100px;\r\n    animation-timing-function: ease-out;\r\n  }\r\n\r\n  25% {\r\n    top: 50px;\r\n    animation-timing-function: ease-in;\r\n  }\r\n\r\n  50% {\r\n    top: 150px;\r\n    animation-timing-function: ease-out;\r\n  }\r\n\r\n  75% {\r\n    top: 75px;\r\n    animation-timing-function: ease-in;\r\n  }\r\n\r\n  to {\r\n    top: 100px;\r\n  }\r\n\r\n}\r\n                <\/pre>\n<p>\n                    The following are all valid <code class=\"\" data-line=\"\">animation-timing-function<\/code> values. See the <a href=\"http:\/\/tympanus.net\/codrops\/css_reference\/timing-function\"><code class=\"\" data-line=\"\">&lt;timing-function&gt;<\/code><\/a> entry for more values and examples.\n                <\/p>\n<pre class=\"brush:css\">\r\nanimation-timing-function: linear;\r\nanimation-timing-function: cubic-bezier(0.42, 0, 1, 1); \/* equivalent to the \"ease-in\" keyword *\/\r\nanimation-timing-function: steps(4, start); \r\nanimation-timing-function: ease-in-out;\r\n                <\/pre>\n<\/p><\/div>\n<div class=\"ct-cssref-demo\">\n<h2>Live Demo<\/h2>\n<p>\n                    The first element in the following demo has a keyframed animation and a timing function applied to the overall animation. The second element has a keyframed animation and timing functions applied to each individual keyframe, not to the animation as a whole. Try changing the animation, or the timing function of the first element and see how it is applied to every keyframe (because it is a keyframed animation). Also try to play with the values of the animation timing functions trying out new ones to get a feel of how it changes an animation.\n                <\/p>\n<p style='font-style:italic;padding: 2rem 0;'>\n    Example demos are temporarily unavailable. Please check back soon.\n  <\/p><\/div>\n<div class=\"ct-cssref-support\">\n<h2>Browser Support<\/h2>\n<div class=\"caniuse\"><div class=\"caniuse-header\"><h3 class=\"caniuse-header-title\">CSS Animation<\/h3><p>Complex method of animating certain properties of an element<\/p>\n<p class=\"status caniuse-header-status\">W3C Working Draft<\/p><p class=\"caniuse-header-supported\">Supported from the following versions:<\/p><\/div><div class=\"caniuse-section\"><h4>Desktop<\/h4><ul class=\"agents caniuse-agents-list\"><li class=\"caniuse-agents-item icon-chrome y\" title=\"Google Chrome - Yes\"><span class=\"caniuse-agents-version version\">43<\/span><\/li><li class=\"caniuse-agents-item icon-firefox y\" title=\"Mozilla Firefox - Yes\"><span class=\"caniuse-agents-version version\">16<\/span><\/li><li class=\"caniuse-agents-item icon-ie y\" title=\"Internet Explorer - Yes\"><span class=\"caniuse-agents-version version\">10<\/span><\/li><li class=\"caniuse-agents-item icon-opera y\" title=\"Opera - Yes\"><span class=\"caniuse-agents-version version\">12<\/span><\/li><li class=\"caniuse-agents-item icon-safari y\" title=\"Apple Safari - Yes\"><span class=\"caniuse-agents-version version\">9<\/span><\/li><\/ul><\/div><div class=\"caniuse-section\"><h4>Mobile \/ Tablet<\/h4><ul class=\"agents caniuse-agents-list\"><li class=\"caniuse-agents-item icon-ios_saf y\" title=\"iOS Safari - Yes\"><span class=\"caniuse-agents-version version\">9.0<\/span><\/li><li class=\"caniuse-agents-item icon-android y\" title=\"Android - Yes\"><span class=\"caniuse-agents-version version\">147<\/span><\/li><li class=\"caniuse-agents-item icon-op_mini n\" title=\"Opera Mini - No\"><span class=\"caniuse-agents-version version\">No<\/span><\/li><li class=\"caniuse-agents-item icon-and_chr y\" title=\"Android Chrome - Yes\"><span class=\"caniuse-agents-version version\">147<\/span><\/li><li class=\"caniuse-agents-item icon-and_ff y\" title=\"Android Firefox - Yes\"><span class=\"caniuse-agents-version version\">150<\/span><\/li><\/ul><\/div><div class=\"caniuse-section caniuse-section-legend\"><p class=\"caniuse-section-text caniuse-section-subtext\t\">* denotes prefix required.<\/p><ul class=\"legend caniuse-legend-list\"><li class=\"caniuse-legend-item caniuse-legend-label\">Supported:<\/li><li class=\"caniuse-legend-item y\">Yes<\/li><li class=\"caniuse-legend-item n\">No<\/li><li class=\"caniuse-legend-item a\">Partially<\/li><li class=\"caniuse-legend-item p\">Polyfill<\/li><\/ul><p class=\"stats caniuse-section-text caniuse-section-stats\">Stats from <a target=\"_blank\" href=\"http:\/\/caniuse.com\/#feat=css-animation\">caniuse.com<\/a><\/p><\/div><\/div><\/div>\n<div class=\"ct-cssref-further-reading\">\n<h2>Further Reading<\/h2>\n<ul>\n<li>\n                       <a href=\"http:\/\/dev.w3.org\/csswg\/css-animations\/#propdef-animation-timing-function\">CSS Animations Module Level 1<\/a>\n                    <\/li>\n<\/ul><\/div>\n","protected":false},"author":67,"menu_order":0,"template":"","format":"standard","class_list":["post-21743","css_reference","type-css_reference","status-publish","format-standard","hentry","css-type-css-property"],"acf":[],"_links":{"self":[{"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/css_reference\/21743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/css_reference"}],"about":[{"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/types\/css_reference"}],"author":[{"embeddable":true,"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/users\/67"}],"version-history":[{"count":0,"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/css_reference\/21743\/revisions"}],"wp:attachment":[{"href":"https:\/\/tympanus.net\/codrops\/wp-json\/wp\/v2\/media?parent=21743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}