5 lines
27 KiB
JSON

{
"id": "api/animations/keyframes",
"title": "keyframes",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/animations\", \"name\": \"@angular/animations\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/animations/keyframes\", \"name\": \"keyframes\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/animations\">@angular/animations</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/animations/src/animation_metadata.ts?message=docs(animations)%3A%20describe%20your%20change...#L823-L871\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/animations/src/animation_metadata.ts#L823-L871\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"keyframes\">keyframes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/keyframes#keyframes\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label function\">function</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Defines a set of animation styles, associating each style with an optional <code>offset</code> value.</p>\n\n \n </section>\n \n \n \n\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"> <span class=\"member-name\"><a href=\"api/animations/keyframes\" class=\"code-anchor\">keyframes</a></span>(steps: <a href=\"api/animations/AnimationStyleMetadata\" class=\"code-anchor\">AnimationStyleMetadata</a>[]): <a href=\"api/animations/AnimationKeyframesSequenceMetadata\" class=\"code-anchor\">AnimationKeyframesSequenceMetadata</a></code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table function-overload-parameters\">\n <tbody>\n \n <tr class=\"function-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>steps</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/animations/AnimationStyleMetadata\" class=\"code-anchor\">AnimationStyleMetadata</a>[]</code></td>\n <td class=\"param-description\">\n <p>A set of animation styles with optional offset data.\nThe optional <code>offset</code> value for a style specifies a percentage of the total animation\ntime at which that style is applied.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n <h6 class=\"no-anchor\" id=\"returns\">Returns</h6>\n <p><code><a href=\"api/animations/AnimationKeyframesSequenceMetadata\" class=\"code-anchor\">AnimationKeyframesSequenceMetadata</a></code>: An object that encapsulates the keyframes data.</p>\n \n \n\n\n \n\n \n</div>\n\n\n \n\n \n\n\n\n \n<section class=\"usage-notes\">\n <h2 id=\"usage-notes\">Usage notes<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/keyframes#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>Use with the <code><a href=\"api/animations/animate\" class=\"code-anchor\">animate</a>()</code> call. Instead of applying animations\nfrom the current state\nto the destination state, keyframes describe how each style entry is applied and at what point\nwithin the animation arc.\nCompare <a href=\"https://www.w3schools.com/css/css3_animations.asp\">CSS Keyframe Animations</a>.</p>\n<h3 id=\"usage\">Usage<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/keyframes#usage\"><i class=\"material-icons\">link</i></a></h3>\n<p>In the following example, the offset values describe\nwhen each <code>backgroundColor</code> value is applied. The color is red at the start, and changes to\nblue when 20% of the total time has elapsed.</p>\n<code-example language=\"typescript\">\n// the provided offset values\n<a href=\"api/animations/animate\" class=\"code-anchor\">animate</a>(\"5s\", <a href=\"api/animations/keyframes\" class=\"code-anchor\">keyframes</a>([\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"red\", offset: 0 }),\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"blue\", offset: 0.2 }),\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"orange\", offset: 0.3 }),\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"black\", offset: 1 })\n]))\n</code-example>\n<p>If there are no <code>offset</code> values specified in the style entries, the offsets\nare calculated automatically.</p>\n<code-example language=\"typescript\">\n<a href=\"api/animations/animate\" class=\"code-anchor\">animate</a>(\"5s\", <a href=\"api/animations/keyframes\" class=\"code-anchor\">keyframes</a>([\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"red\" }) // offset = 0\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"blue\" }) // offset = 0.33\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"orange\" }) // offset = 0.66\n <a href=\"api/animations/style\" class=\"code-anchor\">style</a>({ backgroundColor: \"black\" }) // offset = 1\n]))\n</code-example>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/animations\n - api/animations/AnimationKeyframesSequenceMetadata\n - api/animations/AnimationMetadataType\n - api/animations/animate\n - api/animations/browser/AnimationDriver\n - api/animations/browser/testing/MockAnimationDriver\n - api/animations/browser/testing/MockAnimationPlayer\n - api/animations/group\n - api/animations/style\n - guide/animations\n - guide/migration-renderer\n - guide/transition-and-triggers\n-->\n<!-- links from this doc:\n - /api\n - api/animations\n - api/animations/AnimationKeyframesSequenceMetadata\n - api/animations/AnimationStyleMetadata\n - api/animations/animate\n - api/animations/keyframes#keyframes\n - api/animations/keyframes#usage\n - api/animations/keyframes#usage-notes\n - api/animations/style\n - https://github.com/angular/angular/edit/master/packages/animations/src/animation_metadata.ts?message=docs(animations)%3A%20describe%20your%20change...#L823-L871\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/animations/src/animation_metadata.ts#L823-L871\n - https://www.w3schools.com/css/css3_animations.asp\n-->"
}