5 lines
33 KiB
JSON
5 lines
33 KiB
JSON
{
|
|
"id": "api/animations/trigger",
|
|
"title": "trigger",
|
|
"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/trigger\", \"name\": \"trigger\" } }\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...#L451-L602\" 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#L451-L602\" 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=\"trigger\">trigger<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#trigger\"><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>Creates a named animation trigger, containing a list of <code><a href=\"api/animations/state\" class=\"code-anchor\">state</a>()</code>\nand <code><a href=\"api/animations/transition\" class=\"code-anchor\">transition</a>()</code> entries to be evaluated when the expression\nbound to the trigger changes.</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/trigger\" class=\"code-anchor\">trigger</a></span>(name: string, definitions: <a href=\"api/animations/AnimationMetadata\" class=\"code-anchor\">AnimationMetadata</a>[]): <a href=\"api/animations/AnimationTriggerMetadata\" class=\"code-anchor\">AnimationTriggerMetadata</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>name</code>\n </td>\n <td class=\"param-type\"><code>string</code></td>\n <td class=\"param-description\">\n <p>An identifying string.</p>\n\n </td>\n </tr>\n <tr class=\"function-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>definitions</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/animations/AnimationMetadata\" class=\"code-anchor\">AnimationMetadata</a>[]</code></td>\n <td class=\"param-description\">\n <p>An animation definition object, containing an array of <code><a href=\"api/animations/state\" class=\"code-anchor\">state</a>()</code>\nand <code><a href=\"api/animations/transition\" class=\"code-anchor\">transition</a>()</code> declarations.</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/AnimationTriggerMetadata\" class=\"code-anchor\">AnimationTriggerMetadata</a></code>: An object that encapsulates the trigger 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/trigger#usage-notes\"><i class=\"material-icons\">link</i></a></h2>\n <p>Define an animation trigger in the <code>animations</code> section of <code>@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a></code> metadata.\nIn the template, reference the trigger by name and bind it to a trigger expression that\nevaluates to a defined animation state, using the following format:</p>\n<p><code>[@triggerName]=\"expression\"</code></p>\n<p>Animation trigger bindings convert all values to strings, and then match the\nprevious and current values against any linked transitions.\nBooleans can be specified as <code>1</code> or <code>true</code> and <code>0</code> or <code>false</code>.</p>\n<h3 id=\"usage-example\">Usage Example<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#usage-example\"><i class=\"material-icons\">link</i></a></h3>\n<p>The following example creates an animation trigger reference based on the provided\nname value.\nThe provided animation value is expected to be an array consisting of state and\ntransition declarations.</p>\n<code-example language=\"typescript\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: \"my-component\",\n templateUrl: \"my-component-tpl.html\",\n animations: [\n <a href=\"api/animations/trigger\" class=\"code-anchor\">trigger</a>(\"myAnimationTrigger\", [\n <a href=\"api/animations/state\" class=\"code-anchor\">state</a>(...),\n <a href=\"api/animations/state\" class=\"code-anchor\">state</a>(...),\n <a href=\"api/animations/transition\" class=\"code-anchor\">transition</a>(...),\n <a href=\"api/animations/transition\" class=\"code-anchor\">transition</a>(...)\n ])\n ]\n})\nclass MyComponent {\n myStatusExp = \"something\";\n}\n</code-example>\n<p>The template associated with this component makes use of the defined trigger\nby binding to an element within its template code.</p>\n<code-example language=\"html\">\n<!-- somewhere inside of my-component-tpl.html -->\n<div [@myAnimationTrigger]=\"myStatusExp\">...</div>\n</code-example>\n<h3 id=\"using-an-inline-function\">Using an inline function<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#using-an-inline-function\"><i class=\"material-icons\">link</i></a></h3>\n<p>The <code><a href=\"api/animations/transition\" class=\"code-anchor\">transition</a></code> animation method also supports reading an inline function which can decide\nif its associated animation should be run.</p>\n<code-example language=\"typescript\">\n// this method is run each time the `myAnimationTrigger` <a href=\"api/animations/trigger\" class=\"code-anchor\">trigger</a> value changes.\nfunction myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:\n string]: any}): boolean {\n // notice that `element` and `params` are also available here\n return toState == 'yes-please-animate';\n}\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'my-component',\n templateUrl: 'my-component-tpl.html',\n animations: [\n <a href=\"api/animations/trigger\" class=\"code-anchor\">trigger</a>('myAnimationTrigger', [\n <a href=\"api/animations/transition\" class=\"code-anchor\">transition</a>(myInlineMatcherFn, [\n // the <a href=\"api/animations/animation\" class=\"code-anchor\">animation</a> <a href=\"api/animations/sequence\" class=\"code-anchor\">sequence</a> code\n ]),\n ])\n ]\n})\nclass MyComponent {\n myStatusExp = \"yes-please-animate\";\n}\n</code-example>\n<h3 id=\"disabling-animations\">Disabling Animations<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#disabling-animations\"><i class=\"material-icons\">link</i></a></h3>\n<p>When true, the special animation control binding <code>@.disabled</code> binding prevents\nall animations from rendering.\nPlace the <code>@.disabled</code> binding on an element to disable\nanimations on the element itself, as well as any inner animation triggers\nwithin the element.</p>\n<p>The following example shows how to use this feature:</p>\n<code-example language=\"typescript\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'my-component',\n template: `\n <div [@.disabled]=\"isDisabled\">\n <div [@childAnimation]=\"exp\"></div>\n </div>\n `,\n animations: [\n <a href=\"api/animations/trigger\" class=\"code-anchor\">trigger</a>(\"childAnimation\", [\n // ...\n ])\n ]\n})\nclass MyComponent {\n isDisabled = true;\n exp = '...';\n}\n</code-example>\n<p>When <code>@.disabled</code> is true, it prevents the <code>@childAnimation</code> trigger from animating,\nalong with any inner animations.</p>\n<h3 id=\"disable-animations-application-wide\">Disable animations application-wide<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#disable-animations-application-wide\"><i class=\"material-icons\">link</i></a></h3>\n<p>When an area of the template is set to have animations disabled,\n<strong>all</strong> inner components have their animations disabled as well.\nThis means that you can disable all animations for an app\nby placing a host binding set on <code>@.disabled</code> on the topmost Angular component.</p>\n<code-example language=\"typescript\">\nimport {<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>, <a href=\"api/core/HostBinding\" class=\"code-anchor\">HostBinding</a>} from '@angular/core';\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'app-component',\n templateUrl: 'app.component.html',\n})\nclass AppComponent {\n @<a href=\"api/core/HostBinding\" class=\"code-anchor\">HostBinding</a>('@.disabled')\n public animationsDisabled = true;\n}\n</code-example>\n<h3 id=\"overriding-disablement-of-inner-animations\">Overriding disablement of inner animations<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#overriding-disablement-of-inner-animations\"><i class=\"material-icons\">link</i></a></h3>\n<p>Despite inner animations being disabled, a parent animation can <code><a href=\"api/animations/query\" class=\"code-anchor\">query</a>()</code>\nfor inner elements located in disabled areas of the template and still animate\nthem if needed. This is also the case for when a sub animation is\nqueried by a parent and then later animated using <code><a href=\"api/animations/animateChild\" class=\"code-anchor\">animateChild</a>()</code>.</p>\n<h3 id=\"detecting-when-an-animation-is-disabled\">Detecting when an animation is disabled<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/animations/trigger#detecting-when-an-animation-is-disabled\"><i class=\"material-icons\">link</i></a></h3>\n<p>If a region of the DOM (or the entire application) has its animations disabled, the animation\ntrigger callbacks still fire, but for zero seconds. When the callback fires, it provides\nan instance of an <code><a href=\"api/animations/AnimationEvent\" class=\"code-anchor\">AnimationEvent</a></code>. If animations are disabled,\nthe <code>.disabled</code> flag on the event is true.</p>\n\n</section>\n\n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/animations\n - api/animations/AnimationEvent\n - api/animations/AnimationMetadataType\n - api/animations/AnimationTriggerMetadata\n - api/animations/query\n - api/animations/stagger\n - api/animations/state\n - api/animations/transition\n - api/core/Component\n - api/router/Navigation\n - guide/animations\n - guide/complex-animation-sequences\n - guide/component-interaction\n - guide/elements\n - guide/reusable-animations\n - guide/route-animations\n - guide/router-tutorial-toh\n - guide/testing-components-scenarios\n - guide/transition-and-triggers\n - guide/zone\n-->\n<!-- links from this doc:\n - /api\n - api/animations\n - api/animations/AnimationEvent\n - api/animations/AnimationMetadata\n - api/animations/AnimationTriggerMetadata\n - api/animations/animateChild\n - api/animations/animation\n - api/animations/query\n - api/animations/sequence\n - api/animations/state\n - api/animations/transition\n - api/animations/trigger#detecting-when-an-animation-is-disabled\n - api/animations/trigger#disable-animations-application-wide\n - api/animations/trigger#disabling-animations\n - api/animations/trigger#overriding-disablement-of-inner-animations\n - api/animations/trigger#trigger\n - api/animations/trigger#usage-example\n - api/animations/trigger#usage-notes\n - api/animations/trigger#using-an-inline-function\n - api/core/Component\n - api/core/HostBinding\n - https://github.com/angular/angular/edit/master/packages/animations/src/animation_metadata.ts?message=docs(animations)%3A%20describe%20your%20change...#L451-L602\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/animations/src/animation_metadata.ts#L451-L602\n-->"
|
|
} |