animations.umd.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define('@angular/animations', ['exports'], factory) :
  9. (global = global || self, factory((global.ng = global.ng || {}, global.ng.animations = {})));
  10. }(this, function (exports) { 'use strict';
  11. /**
  12. * An injectable service that produces an animation sequence programmatically within an
  13. * Angular component or directive.
  14. * Provided by the `BrowserAnimationsModule` or `NoopAnimationsModule`.
  15. *
  16. * @usageNotes
  17. *
  18. * To use this service, add it to your component or directive as a dependency.
  19. * The service is instantiated along with your component.
  20. *
  21. * Apps do not typically need to create their own animation players, but if you
  22. * do need to, follow these steps:
  23. *
  24. * 1. Use the `build()` method to create a programmatic animation using the
  25. * `animate()` function. The method returns an `AnimationFactory` instance.
  26. *
  27. * 2. Use the factory object to create an `AnimationPlayer` and attach it to a DOM element.
  28. *
  29. * 3. Use the player object to control the animation programmatically.
  30. *
  31. * For example:
  32. *
  33. * ```ts
  34. * // import the service from BrowserAnimationsModule
  35. * import {AnimationBuilder} from '@angular/animations';
  36. * // require the service as a dependency
  37. * class MyCmp {
  38. * constructor(private _builder: AnimationBuilder) {}
  39. *
  40. * makeAnimation(element: any) {
  41. * // first define a reusable animation
  42. * const myAnimation = this._builder.build([
  43. * style({ width: 0 }),
  44. * animate(1000, style({ width: '100px' }))
  45. * ]);
  46. *
  47. * // use the returned factory object to create a player
  48. * const player = myAnimation.create(element);
  49. *
  50. * player.play();
  51. * }
  52. * }
  53. * ```
  54. *
  55. * @publicApi
  56. */
  57. var AnimationBuilder = /** @class */ (function () {
  58. function AnimationBuilder() {
  59. }
  60. return AnimationBuilder;
  61. }());
  62. /**
  63. * A factory object returned from the `AnimationBuilder`.`build()` method.
  64. *
  65. * @publicApi
  66. */
  67. var AnimationFactory = /** @class */ (function () {
  68. function AnimationFactory() {
  69. }
  70. return AnimationFactory;
  71. }());
  72. /**
  73. * @license
  74. * Copyright Google Inc. All Rights Reserved.
  75. *
  76. * Use of this source code is governed by an MIT-style license that can be
  77. * found in the LICENSE file at https://angular.io/license
  78. */
  79. /**
  80. * Specifies automatic styling.
  81. *
  82. * @publicApi
  83. */
  84. var AUTO_STYLE = '*';
  85. /**
  86. * Creates a named animation trigger, containing a list of `state()`
  87. * and `transition()` entries to be evaluated when the expression
  88. * bound to the trigger changes.
  89. *
  90. * @param name An identifying string.
  91. * @param definitions An animation definition object, containing an array of `state()`
  92. * and `transition()` declarations.
  93. *
  94. * @return An object that encapsulates the trigger data.
  95. *
  96. * @usageNotes
  97. * Define an animation trigger in the `animations` section of `@Component` metadata.
  98. * In the template, reference the trigger by name and bind it to a trigger expression that
  99. * evaluates to a defined animation state, using the following format:
  100. *
  101. * `[@triggerName]="expression"`
  102. *
  103. * Animation trigger bindings convert all values to strings, and then match the
  104. * previous and current values against any linked transitions.
  105. * Booleans can be specified as `1` or `true` and `0` or `false`.
  106. *
  107. * ### Usage Example
  108. *
  109. * The following example creates an animation trigger reference based on the provided
  110. * name value.
  111. * The provided animation value is expected to be an array consisting of state and
  112. * transition declarations.
  113. *
  114. * ```typescript
  115. * @Component({
  116. * selector: "my-component",
  117. * templateUrl: "my-component-tpl.html",
  118. * animations: [
  119. * trigger("myAnimationTrigger", [
  120. * state(...),
  121. * state(...),
  122. * transition(...),
  123. * transition(...)
  124. * ])
  125. * ]
  126. * })
  127. * class MyComponent {
  128. * myStatusExp = "something";
  129. * }
  130. * ```
  131. *
  132. * The template associated with this component makes use of the defined trigger
  133. * by binding to an element within its template code.
  134. *
  135. * ```html
  136. * <!-- somewhere inside of my-component-tpl.html -->
  137. * <div [@myAnimationTrigger]="myStatusExp">...</div>
  138. * ```
  139. *
  140. * ### Using an inline function
  141. * The `transition` animation method also supports reading an inline function which can decide
  142. * if its associated animation should be run.
  143. *
  144. * ```typescript
  145. * // this method is run each time the `myAnimationTrigger` trigger value changes.
  146. * function myInlineMatcherFn(fromState: string, toState: string, element: any, params: {[key:
  147. string]: any}): boolean {
  148. * // notice that `element` and `params` are also available here
  149. * return toState == 'yes-please-animate';
  150. * }
  151. *
  152. * @Component({
  153. * selector: 'my-component',
  154. * templateUrl: 'my-component-tpl.html',
  155. * animations: [
  156. * trigger('myAnimationTrigger', [
  157. * transition(myInlineMatcherFn, [
  158. * // the animation sequence code
  159. * ]),
  160. * ])
  161. * ]
  162. * })
  163. * class MyComponent {
  164. * myStatusExp = "yes-please-animate";
  165. * }
  166. * ```
  167. *
  168. * ### Disabling Animations
  169. * When true, the special animation control binding `@.disabled` binding prevents
  170. * all animations from rendering.
  171. * Place the `@.disabled` binding on an element to disable
  172. * animations on the element itself, as well as any inner animation triggers
  173. * within the element.
  174. *
  175. * The following example shows how to use this feature:
  176. *
  177. * ```typescript
  178. * @Component({
  179. * selector: 'my-component',
  180. * template: `
  181. * <div [@.disabled]="isDisabled">
  182. * <div [@childAnimation]="exp"></div>
  183. * </div>
  184. * `,
  185. * animations: [
  186. * trigger("childAnimation", [
  187. * // ...
  188. * ])
  189. * ]
  190. * })
  191. * class MyComponent {
  192. * isDisabled = true;
  193. * exp = '...';
  194. * }
  195. * ```
  196. *
  197. * When `@.disabled` is true, it prevents the `@childAnimation` trigger from animating,
  198. * along with any inner animations.
  199. *
  200. * ### Disable animations application-wide
  201. * When an area of the template is set to have animations disabled,
  202. * **all** inner components have their animations disabled as well.
  203. * This means that you can disable all animations for an app
  204. * by placing a host binding set on `@.disabled` on the topmost Angular component.
  205. *
  206. * ```typescript
  207. * import {Component, HostBinding} from '@angular/core';
  208. *
  209. * @Component({
  210. * selector: 'app-component',
  211. * templateUrl: 'app.component.html',
  212. * })
  213. * class AppComponent {
  214. * @HostBinding('@.disabled')
  215. * public animationsDisabled = true;
  216. * }
  217. * ```
  218. *
  219. * ### Overriding disablement of inner animations
  220. * Despite inner animations being disabled, a parent animation can `query()`
  221. * for inner elements located in disabled areas of the template and still animate
  222. * them if needed. This is also the case for when a sub animation is
  223. * queried by a parent and then later animated using `animateChild()`.
  224. *
  225. * ### Detecting when an animation is disabled
  226. * If a region of the DOM (or the entire application) has its animations disabled, the animation
  227. * trigger callbacks still fire, but for zero seconds. When the callback fires, it provides
  228. * an instance of an `AnimationEvent`. If animations are disabled,
  229. * the `.disabled` flag on the event is true.
  230. *
  231. * @publicApi
  232. */
  233. function trigger(name, definitions) {
  234. return { type: 7 /* Trigger */, name: name, definitions: definitions, options: {} };
  235. }
  236. /**
  237. * Defines an animation step that combines styling information with timing information.
  238. *
  239. * @param timings Sets `AnimateTimings` for the parent animation.
  240. * A string in the format "duration [delay] [easing]".
  241. * - Duration and delay are expressed as a number and optional time unit,
  242. * such as "1s" or "10ms" for one second and 10 milliseconds, respectively.
  243. * The default unit is milliseconds.
  244. * - The easing value controls how the animation accelerates and decelerates
  245. * during its runtime. Value is one of `ease`, `ease-in`, `ease-out`,
  246. * `ease-in-out`, or a `cubic-bezier()` function call.
  247. * If not supplied, no easing is applied.
  248. *
  249. * For example, the string "1s 100ms ease-out" specifies a duration of
  250. * 1000 milliseconds, and delay of 100 ms, and the "ease-out" easing style,
  251. * which decelerates near the end of the duration.
  252. * @param styles Sets AnimationStyles for the parent animation.
  253. * A function call to either `style()` or `keyframes()`
  254. * that returns a collection of CSS style entries to be applied to the parent animation.
  255. * When null, uses the styles from the destination state.
  256. * This is useful when describing an animation step that will complete an animation;
  257. * see "Animating to the final state" in `transitions()`.
  258. * @returns An object that encapsulates the animation step.
  259. *
  260. * @usageNotes
  261. * Call within an animation `sequence()`, `{@link animations/group group()}`, or
  262. * `transition()` call to specify an animation step
  263. * that applies given style data to the parent animation for a given amount of time.
  264. *
  265. * ### Syntax Examples
  266. * **Timing examples**
  267. *
  268. * The following examples show various `timings` specifications.
  269. * - `animate(500)` : Duration is 500 milliseconds.
  270. * - `animate("1s")` : Duration is 1000 milliseconds.
  271. * - `animate("100ms 0.5s")` : Duration is 100 milliseconds, delay is 500 milliseconds.
  272. * - `animate("5s ease-in")` : Duration is 5000 milliseconds, easing in.
  273. * - `animate("5s 10ms cubic-bezier(.17,.67,.88,.1)")` : Duration is 5000 milliseconds, delay is 10
  274. * milliseconds, easing according to a bezier curve.
  275. *
  276. * **Style examples**
  277. *
  278. * The following example calls `style()` to set a single CSS style.
  279. * ```typescript
  280. * animate(500, style({ background: "red" }))
  281. * ```
  282. * The following example calls `keyframes()` to set a CSS style
  283. * to different values for successive keyframes.
  284. * ```typescript
  285. * animate(500, keyframes(
  286. * [
  287. * style({ background: "blue" })),
  288. * style({ background: "red" }))
  289. * ])
  290. * ```
  291. *
  292. * @publicApi
  293. */
  294. function animate(timings, styles) {
  295. if (styles === void 0) { styles = null; }
  296. return { type: 4 /* Animate */, styles: styles, timings: timings };
  297. }
  298. /**
  299. * @description Defines a list of animation steps to be run in parallel.
  300. *
  301. * @param steps An array of animation step objects.
  302. * - When steps are defined by `style()` or `animate()`
  303. * function calls, each call within the group is executed instantly.
  304. * - To specify offset styles to be applied at a later time, define steps with
  305. * `keyframes()`, or use `animate()` calls with a delay value.
  306. * For example:
  307. *
  308. * ```typescript
  309. * group([
  310. * animate("1s", style({ background: "black" })),
  311. * animate("2s", style({ color: "white" }))
  312. * ])
  313. * ```
  314. *
  315. * @param options An options object containing a delay and
  316. * developer-defined parameters that provide styling defaults and
  317. * can be overridden on invocation.
  318. *
  319. * @return An object that encapsulates the group data.
  320. *
  321. * @usageNotes
  322. * Grouped animations are useful when a series of styles must be
  323. * animated at different starting times and closed off at different ending times.
  324. *
  325. * When called within a `sequence()` or a
  326. * `transition()` call, does not continue to the next
  327. * instruction until all of the inner animation steps have completed.
  328. *
  329. * @publicApi
  330. */
  331. function group(steps, options) {
  332. if (options === void 0) { options = null; }
  333. return { type: 3 /* Group */, steps: steps, options: options };
  334. }
  335. /**
  336. * Defines a list of animation steps to be run sequentially, one by one.
  337. *
  338. * @param steps An array of animation step objects.
  339. * - Steps defined by `style()` calls apply the styling data immediately.
  340. * - Steps defined by `animate()` calls apply the styling data over time
  341. * as specified by the timing data.
  342. *
  343. * ```typescript
  344. * sequence([
  345. * style({ opacity: 0 })),
  346. * animate("1s", style({ opacity: 1 }))
  347. * ])
  348. * ```
  349. *
  350. * @param options An options object containing a delay and
  351. * developer-defined parameters that provide styling defaults and
  352. * can be overridden on invocation.
  353. *
  354. * @return An object that encapsulates the sequence data.
  355. *
  356. * @usageNotes
  357. * When you pass an array of steps to a
  358. * `transition()` call, the steps run sequentially by default.
  359. * Compare this to the `{@link animations/group group()}` call, which runs animation steps in parallel.
  360. *
  361. * When a sequence is used within a `{@link animations/group group()}` or a `transition()` call,
  362. * execution continues to the next instruction only after each of the inner animation
  363. * steps have completed.
  364. *
  365. * @publicApi
  366. **/
  367. function sequence(steps, options) {
  368. if (options === void 0) { options = null; }
  369. return { type: 2 /* Sequence */, steps: steps, options: options };
  370. }
  371. /**
  372. * Declares a key/value object containing CSS properties/styles that
  373. * can then be used for an animation `state`, within an animation `sequence`,
  374. * or as styling data for calls to `animate()` and `keyframes()`.
  375. *
  376. * @param tokens A set of CSS styles or HTML styles associated with an animation state.
  377. * The value can be any of the following:
  378. * - A key-value style pair associating a CSS property with a value.
  379. * - An array of key-value style pairs.
  380. * - An asterisk (*), to use auto-styling, where styles are derived from the element
  381. * being animated and applied to the animation when it starts.
  382. *
  383. * Auto-styling can be used to define a state that depends on layout or other
  384. * environmental factors.
  385. *
  386. * @return An object that encapsulates the style data.
  387. *
  388. * @usageNotes
  389. * The following examples create animation styles that collect a set of
  390. * CSS property values:
  391. *
  392. * ```typescript
  393. * // string values for CSS properties
  394. * style({ background: "red", color: "blue" })
  395. *
  396. * // numerical pixel values
  397. * style({ width: 100, height: 0 })
  398. * ```
  399. *
  400. * The following example uses auto-styling to allow a component to animate from
  401. * a height of 0 up to the height of the parent element:
  402. *
  403. * ```
  404. * style({ height: 0 }),
  405. * animate("1s", style({ height: "*" }))
  406. * ```
  407. *
  408. * @publicApi
  409. **/
  410. function style(tokens) {
  411. return { type: 6 /* Style */, styles: tokens, offset: null };
  412. }
  413. /**
  414. * Declares an animation state within a trigger attached to an element.
  415. *
  416. * @param name One or more names for the defined state in a comma-separated string.
  417. * The following reserved state names can be supplied to define a style for specific use
  418. * cases:
  419. *
  420. * - `void` You can associate styles with this name to be used when
  421. * the element is detached from the application. For example, when an `ngIf` evaluates
  422. * to false, the state of the associated element is void.
  423. * - `*` (asterisk) Indicates the default state. You can associate styles with this name
  424. * to be used as the fallback when the state that is being animated is not declared
  425. * within the trigger.
  426. *
  427. * @param styles A set of CSS styles associated with this state, created using the
  428. * `style()` function.
  429. * This set of styles persists on the element once the state has been reached.
  430. * @param options Parameters that can be passed to the state when it is invoked.
  431. * 0 or more key-value pairs.
  432. * @return An object that encapsulates the new state data.
  433. *
  434. * @usageNotes
  435. * Use the `trigger()` function to register states to an animation trigger.
  436. * Use the `transition()` function to animate between states.
  437. * When a state is active within a component, its associated styles persist on the element,
  438. * even when the animation ends.
  439. *
  440. * @publicApi
  441. **/
  442. function state(name, styles, options) {
  443. return { type: 0 /* State */, name: name, styles: styles, options: options };
  444. }
  445. /**
  446. * Defines a set of animation styles, associating each style with an optional `offset` value.
  447. *
  448. * @param steps A set of animation styles with optional offset data.
  449. * The optional `offset` value for a style specifies a percentage of the total animation
  450. * time at which that style is applied.
  451. * @returns An object that encapsulates the keyframes data.
  452. *
  453. * @usageNotes
  454. * Use with the `animate()` call. Instead of applying animations
  455. * from the current state
  456. * to the destination state, keyframes describe how each style entry is applied and at what point
  457. * within the animation arc.
  458. * Compare [CSS Keyframe Animations](https://www.w3schools.com/css/css3_animations.asp).
  459. *
  460. * ### Usage
  461. *
  462. * In the following example, the offset values describe
  463. * when each `backgroundColor` value is applied. The color is red at the start, and changes to
  464. * blue when 20% of the total time has elapsed.
  465. *
  466. * ```typescript
  467. * // the provided offset values
  468. * animate("5s", keyframes([
  469. * style({ backgroundColor: "red", offset: 0 }),
  470. * style({ backgroundColor: "blue", offset: 0.2 }),
  471. * style({ backgroundColor: "orange", offset: 0.3 }),
  472. * style({ backgroundColor: "black", offset: 1 })
  473. * ]))
  474. * ```
  475. *
  476. * If there are no `offset` values specified in the style entries, the offsets
  477. * are calculated automatically.
  478. *
  479. * ```typescript
  480. * animate("5s", keyframes([
  481. * style({ backgroundColor: "red" }) // offset = 0
  482. * style({ backgroundColor: "blue" }) // offset = 0.33
  483. * style({ backgroundColor: "orange" }) // offset = 0.66
  484. * style({ backgroundColor: "black" }) // offset = 1
  485. * ]))
  486. *```
  487. * @publicApi
  488. */
  489. function keyframes(steps) {
  490. return { type: 5 /* Keyframes */, steps: steps };
  491. }
  492. /**
  493. * Declares an animation transition as a sequence of animation steps to run when a given
  494. * condition is satisfied. The condition is a Boolean expression or function that compares
  495. * the previous and current animation states, and returns true if this transition should occur.
  496. * When the state criteria of a defined transition are met, the associated animation is
  497. * triggered.
  498. *
  499. * @param stateChangeExpr A Boolean expression or function that compares the previous and current
  500. * animation states, and returns true if this transition should occur. Note that "true" and "false"
  501. * match 1 and 0, respectively. An expression is evaluated each time a state change occurs in the
  502. * animation trigger element.
  503. * The animation steps run when the expression evaluates to true.
  504. *
  505. * - A state-change string takes the form "state1 => state2", where each side is a defined animation
  506. * state, or an asterix (*) to refer to a dynamic start or end state.
  507. * - The expression string can contain multiple comma-separated statements;
  508. * for example "state1 => state2, state3 => state4".
  509. * - Special values `:enter` and `:leave` initiate a transition on the entry and exit states,
  510. * equivalent to "void => *" and "* => void".
  511. * - Special values `:increment` and `:decrement` initiate a transition when a numeric value has
  512. * increased or decreased in value.
  513. * - A function is executed each time a state change occurs in the animation trigger element.
  514. * The animation steps run when the function returns true.
  515. *
  516. * @param steps One or more animation objects, as returned by the `animate()` or
  517. * `sequence()` function, that form a transformation from one state to another.
  518. * A sequence is used by default when you pass an array.
  519. * @param options An options object that can contain a delay value for the start of the animation,
  520. * and additional developer-defined parameters. Provided values for additional parameters are used
  521. * as defaults, and override values can be passed to the caller on invocation.
  522. * @returns An object that encapsulates the transition data.
  523. *
  524. * @usageNotes
  525. * The template associated with a component binds an animation trigger to an element.
  526. *
  527. * ```HTML
  528. * <!-- somewhere inside of my-component-tpl.html -->
  529. * <div [@myAnimationTrigger]="myStatusExp">...</div>
  530. * ```
  531. *
  532. * All transitions are defined within an animation trigger,
  533. * along with named states that the transitions change to and from.
  534. *
  535. * ```typescript
  536. * trigger("myAnimationTrigger", [
  537. * // define states
  538. * state("on", style({ background: "green" })),
  539. * state("off", style({ background: "grey" })),
  540. * ...]
  541. * ```
  542. *
  543. * Note that when you call the `sequence()` function within a `{@link animations/group group()}`
  544. * or a `transition()` call, execution does not continue to the next instruction
  545. * until each of the inner animation steps have completed.
  546. *
  547. * ### Syntax examples
  548. *
  549. * The following examples define transitions between the two defined states (and default states),
  550. * using various options:
  551. *
  552. * ```typescript
  553. * // Transition occurs when the state value
  554. * // bound to "myAnimationTrigger" changes from "on" to "off"
  555. * transition("on => off", animate(500))
  556. * // Run the same animation for both directions
  557. * transition("on <=> off", animate(500))
  558. * // Define multiple state-change pairs separated by commas
  559. * transition("on => off, off => void", animate(500))
  560. * ```
  561. *
  562. * ### Special values for state-change expressions
  563. *
  564. * - Catch-all state change for when an element is inserted into the page and the
  565. * destination state is unknown:
  566. *
  567. * ```typescript
  568. * transition("void => *", [
  569. * style({ opacity: 0 }),
  570. * animate(500)
  571. * ])
  572. * ```
  573. *
  574. * - Capture a state change between any states:
  575. *
  576. * `transition("* => *", animate("1s 0s"))`
  577. *
  578. * - Entry and exit transitions:
  579. *
  580. * ```typescript
  581. * transition(":enter", [
  582. * style({ opacity: 0 }),
  583. * animate(500, style({ opacity: 1 }))
  584. * ]),
  585. * transition(":leave", [
  586. * animate(500, style({ opacity: 0 }))
  587. * ])
  588. * ```
  589. *
  590. * - Use `:increment` and `:decrement` to initiate transitions:
  591. *
  592. * ```typescript
  593. * transition(":increment", group([
  594. * query(':enter', [
  595. * style({ left: '100%' }),
  596. * animate('0.5s ease-out', style('*'))
  597. * ]),
  598. * query(':leave', [
  599. * animate('0.5s ease-out', style({ left: '-100%' }))
  600. * ])
  601. * ]))
  602. *
  603. * transition(":decrement", group([
  604. * query(':enter', [
  605. * style({ left: '100%' }),
  606. * animate('0.5s ease-out', style('*'))
  607. * ]),
  608. * query(':leave', [
  609. * animate('0.5s ease-out', style({ left: '-100%' }))
  610. * ])
  611. * ]))
  612. * ```
  613. *
  614. * ### State-change functions
  615. *
  616. * Here is an example of a `fromState` specified as a state-change function that invokes an
  617. * animation when true:
  618. *
  619. * ```typescript
  620. * transition((fromState, toState) =>
  621. * {
  622. * return fromState == "off" && toState == "on";
  623. * },
  624. * animate("1s 0s"))
  625. * ```
  626. *
  627. * ### Animating to the final state
  628. *
  629. * If the final step in a transition is a call to `animate()` that uses a timing value
  630. * with no style data, that step is automatically considered the final animation arc,
  631. * for the element to reach the final state. Angular automatically adds or removes
  632. * CSS styles to ensure that the element is in the correct final state.
  633. *
  634. * The following example defines a transition that starts by hiding the element,
  635. * then makes sure that it animates properly to whatever state is currently active for trigger:
  636. *
  637. * ```typescript
  638. * transition("void => *", [
  639. * style({ opacity: 0 }),
  640. * animate(500)
  641. * ])
  642. * ```
  643. * ### Boolean value matching
  644. * If a trigger binding value is a Boolean, it can be matched using a transition expression
  645. * that compares true and false or 1 and 0. For example:
  646. *
  647. * ```
  648. * // in the template
  649. * <div [@openClose]="open ? true : false">...</div>
  650. * // in the component metadata
  651. * trigger('openClose', [
  652. * state('true', style({ height: '*' })),
  653. * state('false', style({ height: '0px' })),
  654. * transition('false <=> true', animate(500))
  655. * ])
  656. * ```
  657. *
  658. * @publicApi
  659. **/
  660. function transition(stateChangeExpr, steps, options) {
  661. if (options === void 0) { options = null; }
  662. return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options: options };
  663. }
  664. /**
  665. * Produces a reusable animation that can be invoked in another animation or sequence,
  666. * by calling the `useAnimation()` function.
  667. *
  668. * @param steps One or more animation objects, as returned by the `animate()`
  669. * or `sequence()` function, that form a transformation from one state to another.
  670. * A sequence is used by default when you pass an array.
  671. * @param options An options object that can contain a delay value for the start of the
  672. * animation, and additional developer-defined parameters.
  673. * Provided values for additional parameters are used as defaults,
  674. * and override values can be passed to the caller on invocation.
  675. * @returns An object that encapsulates the animation data.
  676. *
  677. * @usageNotes
  678. * The following example defines a reusable animation, providing some default parameter
  679. * values.
  680. *
  681. * ```typescript
  682. * var fadeAnimation = animation([
  683. * style({ opacity: '{{ start }}' }),
  684. * animate('{{ time }}',
  685. * style({ opacity: '{{ end }}'}))
  686. * ],
  687. * { params: { time: '1000ms', start: 0, end: 1 }});
  688. * ```
  689. *
  690. * The following invokes the defined animation with a call to `useAnimation()`,
  691. * passing in override parameter values.
  692. *
  693. * ```js
  694. * useAnimation(fadeAnimation, {
  695. * params: {
  696. * time: '2s',
  697. * start: 1,
  698. * end: 0
  699. * }
  700. * })
  701. * ```
  702. *
  703. * If any of the passed-in parameter values are missing from this call,
  704. * the default values are used. If one or more parameter values are missing before a step is
  705. * animated, `useAnimation()` throws an error.
  706. *
  707. * @publicApi
  708. */
  709. function animation(steps, options) {
  710. if (options === void 0) { options = null; }
  711. return { type: 8 /* Reference */, animation: steps, options: options };
  712. }
  713. /**
  714. * Executes a queried inner animation element within an animation sequence.
  715. *
  716. * @param options An options object that can contain a delay value for the start of the
  717. * animation, and additional override values for developer-defined parameters.
  718. * @return An object that encapsulates the child animation data.
  719. *
  720. * @usageNotes
  721. * Each time an animation is triggered in Angular, the parent animation
  722. * has priority and any child animations are blocked. In order
  723. * for a child animation to run, the parent animation must query each of the elements
  724. * containing child animations, and run them using this function.
  725. *
  726. * Note that this feature is designed to be used with `query()` and it will only work
  727. * with animations that are assigned using the Angular animation library. CSS keyframes
  728. * and transitions are not handled by this API.
  729. *
  730. * @publicApi
  731. */
  732. function animateChild(options) {
  733. if (options === void 0) { options = null; }
  734. return { type: 9 /* AnimateChild */, options: options };
  735. }
  736. /**
  737. * Starts a reusable animation that is created using the `animation()` function.
  738. *
  739. * @param animation The reusable animation to start.
  740. * @param options An options object that can contain a delay value for the start of
  741. * the animation, and additional override values for developer-defined parameters.
  742. * @return An object that contains the animation parameters.
  743. *
  744. * @publicApi
  745. */
  746. function useAnimation(animation, options) {
  747. if (options === void 0) { options = null; }
  748. return { type: 10 /* AnimateRef */, animation: animation, options: options };
  749. }
  750. /**
  751. * Finds one or more inner elements within the current element that is
  752. * being animated within a sequence. Use with `animate()`.
  753. *
  754. * @param selector The element to query, or a set of elements that contain Angular-specific
  755. * characteristics, specified with one or more of the following tokens.
  756. * - `query(":enter")` or `query(":leave")` : Query for newly inserted/removed elements.
  757. * - `query(":animating")` : Query all currently animating elements.
  758. * - `query("@triggerName")` : Query elements that contain an animation trigger.
  759. * - `query("@*")` : Query all elements that contain an animation triggers.
  760. * - `query(":self")` : Include the current element into the animation sequence.
  761. *
  762. * @param animation One or more animation steps to apply to the queried element or elements.
  763. * An array is treated as an animation sequence.
  764. * @param options An options object. Use the 'limit' field to limit the total number of
  765. * items to collect.
  766. * @return An object that encapsulates the query data.
  767. *
  768. * @usageNotes
  769. * Tokens can be merged into a combined query selector string. For example:
  770. *
  771. * ```typescript
  772. * query(':self, .record:enter, .record:leave, @subTrigger', [...])
  773. * ```
  774. *
  775. * The `query()` function collects multiple elements and works internally by using
  776. * `element.querySelectorAll`. Use the `limit` field of an options object to limit
  777. * the total number of items to be collected. For example:
  778. *
  779. * ```js
  780. * query('div', [
  781. * animate(...),
  782. * animate(...)
  783. * ], { limit: 1 })
  784. * ```
  785. *
  786. * By default, throws an error when zero items are found. Set the
  787. * `optional` flag to ignore this error. For example:
  788. *
  789. * ```js
  790. * query('.some-element-that-may-not-be-there', [
  791. * animate(...),
  792. * animate(...)
  793. * ], { optional: true })
  794. * ```
  795. *
  796. * ### Usage Example
  797. *
  798. * The following example queries for inner elements and animates them
  799. * individually using `animate()`.
  800. *
  801. * ```typescript
  802. * @Component({
  803. * selector: 'inner',
  804. * template: `
  805. * <div [@queryAnimation]="exp">
  806. * <h1>Title</h1>
  807. * <div class="content">
  808. * Blah blah blah
  809. * </div>
  810. * </div>
  811. * `,
  812. * animations: [
  813. * trigger('queryAnimation', [
  814. * transition('* => goAnimate', [
  815. * // hide the inner elements
  816. * query('h1', style({ opacity: 0 })),
  817. * query('.content', style({ opacity: 0 })),
  818. *
  819. * // animate the inner elements in, one by one
  820. * query('h1', animate(1000, style({ opacity: 1 }))),
  821. * query('.content', animate(1000, style({ opacity: 1 }))),
  822. * ])
  823. * ])
  824. * ]
  825. * })
  826. * class Cmp {
  827. * exp = '';
  828. *
  829. * goAnimate() {
  830. * this.exp = 'goAnimate';
  831. * }
  832. * }
  833. * ```
  834. *
  835. * @publicApi
  836. */
  837. function query(selector, animation, options) {
  838. if (options === void 0) { options = null; }
  839. return { type: 11 /* Query */, selector: selector, animation: animation, options: options };
  840. }
  841. /**
  842. * Use within an animation `query()` call to issue a timing gap after
  843. * each queried item is animated.
  844. *
  845. * @param timings A delay value.
  846. * @param animation One ore more animation steps.
  847. * @returns An object that encapsulates the stagger data.
  848. *
  849. * @usageNotes
  850. * In the following example, a container element wraps a list of items stamped out
  851. * by an `ngFor`. The container element contains an animation trigger that will later be set
  852. * to query for each of the inner items.
  853. *
  854. * Each time items are added, the opacity fade-in animation runs,
  855. * and each removed item is faded out.
  856. * When either of these animations occur, the stagger effect is
  857. * applied after each item's animation is started.
  858. *
  859. * ```html
  860. * <!-- list.component.html -->
  861. * <button (click)="toggle()">Show / Hide Items</button>
  862. * <hr />
  863. * <div [@listAnimation]="items.length">
  864. * <div *ngFor="let item of items">
  865. * {{ item }}
  866. * </div>
  867. * </div>
  868. * ```
  869. *
  870. * Here is the component code:
  871. *
  872. * ```typescript
  873. * import {trigger, transition, style, animate, query, stagger} from '@angular/animations';
  874. * @Component({
  875. * templateUrl: 'list.component.html',
  876. * animations: [
  877. * trigger('listAnimation', [
  878. * ...
  879. * ])
  880. * ]
  881. * })
  882. * class ListComponent {
  883. * items = [];
  884. *
  885. * showItems() {
  886. * this.items = [0,1,2,3,4];
  887. * }
  888. *
  889. * hideItems() {
  890. * this.items = [];
  891. * }
  892. *
  893. * toggle() {
  894. * this.items.length ? this.hideItems() : this.showItems();
  895. * }
  896. * }
  897. * ```
  898. *
  899. * Here is the animation trigger code:
  900. *
  901. * ```typescript
  902. * trigger('listAnimation', [
  903. * transition('* => *', [ // each time the binding value changes
  904. * query(':leave', [
  905. * stagger(100, [
  906. * animate('0.5s', style({ opacity: 0 }))
  907. * ])
  908. * ]),
  909. * query(':enter', [
  910. * style({ opacity: 0 }),
  911. * stagger(100, [
  912. * animate('0.5s', style({ opacity: 1 }))
  913. * ])
  914. * ])
  915. * ])
  916. * ])
  917. * ```
  918. *
  919. * @publicApi
  920. */
  921. function stagger(timings, animation) {
  922. return { type: 12 /* Stagger */, timings: timings, animation: animation };
  923. }
  924. /**
  925. * @license
  926. * Copyright Google Inc. All Rights Reserved.
  927. *
  928. * Use of this source code is governed by an MIT-style license that can be
  929. * found in the LICENSE file at https://angular.io/license
  930. */
  931. function scheduleMicroTask(cb) {
  932. Promise.resolve(null).then(cb);
  933. }
  934. /**
  935. * @license
  936. * Copyright Google Inc. All Rights Reserved.
  937. *
  938. * Use of this source code is governed by an MIT-style license that can be
  939. * found in the LICENSE file at https://angular.io/license
  940. */
  941. /**
  942. * An empty programmatic controller for reusable animations.
  943. * Used internally when animations are disabled, to avoid
  944. * checking for the null case when an animation player is expected.
  945. *
  946. * @see `animate()`
  947. * @see `AnimationPlayer`
  948. * @see `GroupPlayer`
  949. *
  950. * @publicApi
  951. */
  952. var NoopAnimationPlayer = /** @class */ (function () {
  953. function NoopAnimationPlayer(duration, delay) {
  954. if (duration === void 0) { duration = 0; }
  955. if (delay === void 0) { delay = 0; }
  956. this._onDoneFns = [];
  957. this._onStartFns = [];
  958. this._onDestroyFns = [];
  959. this._started = false;
  960. this._destroyed = false;
  961. this._finished = false;
  962. this.parentPlayer = null;
  963. this.totalTime = duration + delay;
  964. }
  965. NoopAnimationPlayer.prototype._onFinish = function () {
  966. if (!this._finished) {
  967. this._finished = true;
  968. this._onDoneFns.forEach(function (fn) { return fn(); });
  969. this._onDoneFns = [];
  970. }
  971. };
  972. NoopAnimationPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
  973. NoopAnimationPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
  974. NoopAnimationPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); };
  975. NoopAnimationPlayer.prototype.hasStarted = function () { return this._started; };
  976. NoopAnimationPlayer.prototype.init = function () { };
  977. NoopAnimationPlayer.prototype.play = function () {
  978. if (!this.hasStarted()) {
  979. this._onStart();
  980. this.triggerMicrotask();
  981. }
  982. this._started = true;
  983. };
  984. /** @internal */
  985. NoopAnimationPlayer.prototype.triggerMicrotask = function () {
  986. var _this = this;
  987. scheduleMicroTask(function () { return _this._onFinish(); });
  988. };
  989. NoopAnimationPlayer.prototype._onStart = function () {
  990. this._onStartFns.forEach(function (fn) { return fn(); });
  991. this._onStartFns = [];
  992. };
  993. NoopAnimationPlayer.prototype.pause = function () { };
  994. NoopAnimationPlayer.prototype.restart = function () { };
  995. NoopAnimationPlayer.prototype.finish = function () { this._onFinish(); };
  996. NoopAnimationPlayer.prototype.destroy = function () {
  997. if (!this._destroyed) {
  998. this._destroyed = true;
  999. if (!this.hasStarted()) {
  1000. this._onStart();
  1001. }
  1002. this.finish();
  1003. this._onDestroyFns.forEach(function (fn) { return fn(); });
  1004. this._onDestroyFns = [];
  1005. }
  1006. };
  1007. NoopAnimationPlayer.prototype.reset = function () { };
  1008. NoopAnimationPlayer.prototype.setPosition = function (position) { };
  1009. NoopAnimationPlayer.prototype.getPosition = function () { return 0; };
  1010. /** @internal */
  1011. NoopAnimationPlayer.prototype.triggerCallback = function (phaseName) {
  1012. var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
  1013. methods.forEach(function (fn) { return fn(); });
  1014. methods.length = 0;
  1015. };
  1016. return NoopAnimationPlayer;
  1017. }());
  1018. /**
  1019. * @license
  1020. * Copyright Google Inc. All Rights Reserved.
  1021. *
  1022. * Use of this source code is governed by an MIT-style license that can be
  1023. * found in the LICENSE file at https://angular.io/license
  1024. */
  1025. /**
  1026. * A programmatic controller for a group of reusable animations.
  1027. * Used internally to control animations.
  1028. *
  1029. * @see `AnimationPlayer`
  1030. * @see `{@link animations/group group()}`
  1031. *
  1032. */
  1033. var AnimationGroupPlayer = /** @class */ (function () {
  1034. function AnimationGroupPlayer(_players) {
  1035. var _this = this;
  1036. this._onDoneFns = [];
  1037. this._onStartFns = [];
  1038. this._finished = false;
  1039. this._started = false;
  1040. this._destroyed = false;
  1041. this._onDestroyFns = [];
  1042. this.parentPlayer = null;
  1043. this.totalTime = 0;
  1044. this.players = _players;
  1045. var doneCount = 0;
  1046. var destroyCount = 0;
  1047. var startCount = 0;
  1048. var total = this.players.length;
  1049. if (total == 0) {
  1050. scheduleMicroTask(function () { return _this._onFinish(); });
  1051. }
  1052. else {
  1053. this.players.forEach(function (player) {
  1054. player.onDone(function () {
  1055. if (++doneCount == total) {
  1056. _this._onFinish();
  1057. }
  1058. });
  1059. player.onDestroy(function () {
  1060. if (++destroyCount == total) {
  1061. _this._onDestroy();
  1062. }
  1063. });
  1064. player.onStart(function () {
  1065. if (++startCount == total) {
  1066. _this._onStart();
  1067. }
  1068. });
  1069. });
  1070. }
  1071. this.totalTime = this.players.reduce(function (time, player) { return Math.max(time, player.totalTime); }, 0);
  1072. }
  1073. AnimationGroupPlayer.prototype._onFinish = function () {
  1074. if (!this._finished) {
  1075. this._finished = true;
  1076. this._onDoneFns.forEach(function (fn) { return fn(); });
  1077. this._onDoneFns = [];
  1078. }
  1079. };
  1080. AnimationGroupPlayer.prototype.init = function () { this.players.forEach(function (player) { return player.init(); }); };
  1081. AnimationGroupPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); };
  1082. AnimationGroupPlayer.prototype._onStart = function () {
  1083. if (!this.hasStarted()) {
  1084. this._started = true;
  1085. this._onStartFns.forEach(function (fn) { return fn(); });
  1086. this._onStartFns = [];
  1087. }
  1088. };
  1089. AnimationGroupPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); };
  1090. AnimationGroupPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); };
  1091. AnimationGroupPlayer.prototype.hasStarted = function () { return this._started; };
  1092. AnimationGroupPlayer.prototype.play = function () {
  1093. if (!this.parentPlayer) {
  1094. this.init();
  1095. }
  1096. this._onStart();
  1097. this.players.forEach(function (player) { return player.play(); });
  1098. };
  1099. AnimationGroupPlayer.prototype.pause = function () { this.players.forEach(function (player) { return player.pause(); }); };
  1100. AnimationGroupPlayer.prototype.restart = function () { this.players.forEach(function (player) { return player.restart(); }); };
  1101. AnimationGroupPlayer.prototype.finish = function () {
  1102. this._onFinish();
  1103. this.players.forEach(function (player) { return player.finish(); });
  1104. };
  1105. AnimationGroupPlayer.prototype.destroy = function () { this._onDestroy(); };
  1106. AnimationGroupPlayer.prototype._onDestroy = function () {
  1107. if (!this._destroyed) {
  1108. this._destroyed = true;
  1109. this._onFinish();
  1110. this.players.forEach(function (player) { return player.destroy(); });
  1111. this._onDestroyFns.forEach(function (fn) { return fn(); });
  1112. this._onDestroyFns = [];
  1113. }
  1114. };
  1115. AnimationGroupPlayer.prototype.reset = function () {
  1116. this.players.forEach(function (player) { return player.reset(); });
  1117. this._destroyed = false;
  1118. this._finished = false;
  1119. this._started = false;
  1120. };
  1121. AnimationGroupPlayer.prototype.setPosition = function (p) {
  1122. var timeAtPosition = p * this.totalTime;
  1123. this.players.forEach(function (player) {
  1124. var position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
  1125. player.setPosition(position);
  1126. });
  1127. };
  1128. AnimationGroupPlayer.prototype.getPosition = function () {
  1129. var min = 0;
  1130. this.players.forEach(function (player) {
  1131. var p = player.getPosition();
  1132. min = Math.min(p, min);
  1133. });
  1134. return min;
  1135. };
  1136. AnimationGroupPlayer.prototype.beforeDestroy = function () {
  1137. this.players.forEach(function (player) {
  1138. if (player.beforeDestroy) {
  1139. player.beforeDestroy();
  1140. }
  1141. });
  1142. };
  1143. /** @internal */
  1144. AnimationGroupPlayer.prototype.triggerCallback = function (phaseName) {
  1145. var methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
  1146. methods.forEach(function (fn) { return fn(); });
  1147. methods.length = 0;
  1148. };
  1149. return AnimationGroupPlayer;
  1150. }());
  1151. /**
  1152. * @license
  1153. * Copyright Google Inc. All Rights Reserved.
  1154. *
  1155. * Use of this source code is governed by an MIT-style license that can be
  1156. * found in the LICENSE file at https://angular.io/license
  1157. */
  1158. var ɵPRE_STYLE = '!';
  1159. /**
  1160. * @license
  1161. * Copyright Google Inc. All Rights Reserved.
  1162. *
  1163. * Use of this source code is governed by an MIT-style license that can be
  1164. * found in the LICENSE file at https://angular.io/license
  1165. */
  1166. /**
  1167. * @license
  1168. * Copyright Google Inc. All Rights Reserved.
  1169. *
  1170. * Use of this source code is governed by an MIT-style license that can be
  1171. * found in the LICENSE file at https://angular.io/license
  1172. */
  1173. /**
  1174. * @license
  1175. * Copyright Google Inc. All Rights Reserved.
  1176. *
  1177. * Use of this source code is governed by an MIT-style license that can be
  1178. * found in the LICENSE file at https://angular.io/license
  1179. */
  1180. /**
  1181. * Generated bundle index. Do not edit.
  1182. */
  1183. exports.AnimationBuilder = AnimationBuilder;
  1184. exports.AnimationFactory = AnimationFactory;
  1185. exports.AUTO_STYLE = AUTO_STYLE;
  1186. exports.animate = animate;
  1187. exports.animateChild = animateChild;
  1188. exports.animation = animation;
  1189. exports.group = group;
  1190. exports.keyframes = keyframes;
  1191. exports.query = query;
  1192. exports.sequence = sequence;
  1193. exports.stagger = stagger;
  1194. exports.state = state;
  1195. exports.style = style;
  1196. exports.transition = transition;
  1197. exports.trigger = trigger;
  1198. exports.useAnimation = useAnimation;
  1199. exports.NoopAnimationPlayer = NoopAnimationPlayer;
  1200. exports.ɵPRE_STYLE = ɵPRE_STYLE;
  1201. exports.ɵAnimationGroupPlayer = AnimationGroupPlayer;
  1202. Object.defineProperty(exports, '__esModule', { value: true });
  1203. }));
  1204. //# sourceMappingURL=animations.umd.js.map