@angular/animations 13.2.0-next.0 → 13.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/animations.d.ts +123 -145
- package/browser/browser.d.ts +3 -3
- package/browser/testing/testing.d.ts +1 -1
- package/esm2020/browser/src/dsl/animation_ast_builder.mjs +1 -1
- package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +2 -2
- package/esm2020/browser/src/dsl/element_instruction_map.mjs +3 -10
- package/esm2020/browser/src/render/animation_driver.mjs +3 -3
- package/esm2020/browser/src/render/transition_animation_engine.mjs +9 -2
- package/esm2020/browser/src/render/web_animations/web_animations_player.mjs +7 -4
- package/esm2020/browser/src/util.mjs +1 -3
- package/esm2020/src/animation_metadata.mjs +123 -145
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/animations.mjs +123 -145
- package/fesm2015/animations.mjs.map +1 -1
- package/fesm2015/browser/testing.mjs +1 -1
- package/fesm2015/browser.mjs +21 -20
- package/fesm2015/browser.mjs.map +1 -1
- package/fesm2020/animations.mjs +123 -145
- package/fesm2020/animations.mjs.map +1 -1
- package/fesm2020/browser/testing.mjs +1 -1
- package/fesm2020/browser.mjs +21 -20
- package/fesm2020/browser.mjs.map +1 -1
- package/package.json +2 -2
package/fesm2015/animations.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v13.2.0-next.
|
|
2
|
+
* @license Angular v13.2.0-next.1
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -480,170 +480,148 @@ function keyframes(steps) {
|
|
|
480
480
|
return { type: 5 /* Keyframes */, steps };
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
|
-
* Declares an animation transition
|
|
484
|
-
* condition is satisfied. The condition is a Boolean expression or function that compares
|
|
485
|
-
* the previous and current animation states, and returns true if this transition should occur.
|
|
486
|
-
* When the state criteria of a defined transition are met, the associated animation is
|
|
487
|
-
* triggered.
|
|
488
|
-
*
|
|
489
|
-
* @param stateChangeExpr A Boolean expression or function that compares the previous and current
|
|
490
|
-
* animation states, and returns true if this transition should occur. Note that "true" and "false"
|
|
491
|
-
* match 1 and 0, respectively. An expression is evaluated each time a state change occurs in the
|
|
492
|
-
* animation trigger element.
|
|
493
|
-
* The animation steps run when the expression evaluates to true.
|
|
494
|
-
*
|
|
495
|
-
* - A state-change string takes the form "state1 => state2", where each side is a defined animation
|
|
496
|
-
* state, or an asterisk (*) to refer to a dynamic start or end state.
|
|
497
|
-
* - The expression string can contain multiple comma-separated statements;
|
|
498
|
-
* for example "state1 => state2, state3 => state4".
|
|
499
|
-
* - Special values `:enter` and `:leave` initiate a transition on the entry and exit states,
|
|
500
|
-
* equivalent to "void => *" and "* => void".
|
|
501
|
-
* - Special values `:increment` and `:decrement` initiate a transition when a numeric value has
|
|
502
|
-
* increased or decreased in value.
|
|
503
|
-
* - A function is executed each time a state change occurs in the animation trigger element.
|
|
504
|
-
* The animation steps run when the function returns true.
|
|
505
|
-
*
|
|
506
|
-
* @param steps One or more animation objects, as returned by the `animate()` or
|
|
507
|
-
* `sequence()` function, that form a transformation from one state to another.
|
|
508
|
-
* A sequence is used by default when you pass an array.
|
|
509
|
-
* @param options An options object that can contain a delay value for the start of the animation,
|
|
510
|
-
* and additional developer-defined parameters. Provided values for additional parameters are used
|
|
511
|
-
* as defaults, and override values can be passed to the caller on invocation.
|
|
512
|
-
* @returns An object that encapsulates the transition data.
|
|
483
|
+
* Declares an animation transition which is played when a certain specified condition is met.
|
|
513
484
|
*
|
|
514
|
-
* @
|
|
515
|
-
*
|
|
485
|
+
* @param stateChangeExpr A string with a specific format or a function that specifies when the
|
|
486
|
+
* animation transition should occur (see [State Change Expression](#state-change-expression)).
|
|
516
487
|
*
|
|
517
|
-
*
|
|
518
|
-
* <!-- somewhere inside of my-component-tpl.html -->
|
|
519
|
-
* <div [@myAnimationTrigger]="myStatusExp">...</div>
|
|
520
|
-
* ```
|
|
488
|
+
* @param steps One or more animation objects that represent the animation's instructions.
|
|
521
489
|
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
490
|
+
* @param options An options object that can be used to specify a delay for the animation or provide
|
|
491
|
+
* custom parameters for it.
|
|
524
492
|
*
|
|
525
|
-
*
|
|
526
|
-
* trigger("myAnimationTrigger", [
|
|
527
|
-
* // define states
|
|
528
|
-
* state("on", style({ background: "green" })),
|
|
529
|
-
* state("off", style({ background: "grey" })),
|
|
530
|
-
* ...]
|
|
531
|
-
* ```
|
|
532
|
-
*
|
|
533
|
-
* Note that when you call the `sequence()` function within a `{@link animations/group group()}`
|
|
534
|
-
* or a `transition()` call, execution does not continue to the next instruction
|
|
535
|
-
* until each of the inner animation steps have completed.
|
|
536
|
-
*
|
|
537
|
-
* ### Syntax examples
|
|
538
|
-
*
|
|
539
|
-
* The following examples define transitions between the two defined states (and default states),
|
|
540
|
-
* using various options:
|
|
541
|
-
*
|
|
542
|
-
* ```typescript
|
|
543
|
-
* // Transition occurs when the state value
|
|
544
|
-
* // bound to "myAnimationTrigger" changes from "on" to "off"
|
|
545
|
-
* transition("on => off", animate(500))
|
|
546
|
-
* // Run the same animation for both directions
|
|
547
|
-
* transition("on <=> off", animate(500))
|
|
548
|
-
* // Define multiple state-change pairs separated by commas
|
|
549
|
-
* transition("on => off, off => void", animate(500))
|
|
550
|
-
* ```
|
|
551
|
-
*
|
|
552
|
-
* ### Special values for state-change expressions
|
|
553
|
-
*
|
|
554
|
-
* - Catch-all state change for when an element is inserted into the page and the
|
|
555
|
-
* destination state is unknown:
|
|
493
|
+
* @returns An object that encapsulates the transition data.
|
|
556
494
|
*
|
|
557
|
-
*
|
|
558
|
-
* transition("void => *", [
|
|
559
|
-
* style({ opacity: 0 }),
|
|
560
|
-
* animate(500)
|
|
561
|
-
* ])
|
|
562
|
-
* ```
|
|
495
|
+
* @usageNotes
|
|
563
496
|
*
|
|
564
|
-
*
|
|
497
|
+
* ### State Change Expression
|
|
498
|
+
*
|
|
499
|
+
* The State Change Expression instructs Angular when to run the transition's animations, it can
|
|
500
|
+
*either be
|
|
501
|
+
* - a string with a specific syntax
|
|
502
|
+
* - or a function that compares the previous and current state (value of the expression bound to
|
|
503
|
+
* the element's trigger) and returns `true` if the transition should occur or `false` otherwise
|
|
504
|
+
*
|
|
505
|
+
* The string format can be:
|
|
506
|
+
* - `fromState => toState`, which indicates that the transition's animations should occur then the
|
|
507
|
+
* expression bound to the trigger's element goes from `fromState` to `toState`
|
|
508
|
+
*
|
|
509
|
+
* _Example:_
|
|
510
|
+
* ```typescript
|
|
511
|
+
* transition('open => closed', animate('.5s ease-out', style({ height: 0 }) ))
|
|
512
|
+
* ```
|
|
513
|
+
*
|
|
514
|
+
* - `fromState <=> toState`, which indicates that the transition's animations should occur then
|
|
515
|
+
* the expression bound to the trigger's element goes from `fromState` to `toState` or vice versa
|
|
516
|
+
*
|
|
517
|
+
* _Example:_
|
|
518
|
+
* ```typescript
|
|
519
|
+
* transition('enabled <=> disabled', animate('1s cubic-bezier(0.8,0.3,0,1)'))
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* - `:enter`/`:leave`, which indicates that the transition's animations should occur when the
|
|
523
|
+
* element enters or exists the DOM
|
|
524
|
+
*
|
|
525
|
+
* _Example:_
|
|
526
|
+
* ```typescript
|
|
527
|
+
* transition(':enter', [
|
|
528
|
+
* style({ opacity: 0 }),
|
|
529
|
+
* animate('500ms', style({ opacity: 1 }))
|
|
530
|
+
* ])
|
|
531
|
+
* ```
|
|
532
|
+
*
|
|
533
|
+
* - `:increment`/`:decrement`, which indicates that the transition's animations should occur when
|
|
534
|
+
* the numerical expression bound to the trigger's element has increased in value or decreased
|
|
535
|
+
*
|
|
536
|
+
* _Example:_
|
|
537
|
+
* ```typescript
|
|
538
|
+
* transition(':increment', query('@counter', animateChild()))
|
|
539
|
+
* ```
|
|
540
|
+
*
|
|
541
|
+
* - a sequence of any of the above divided by commas, which indicates that transition's animations
|
|
542
|
+
* should occur whenever one of the state change expressions matches
|
|
543
|
+
*
|
|
544
|
+
* _Example:_
|
|
545
|
+
* ```typescript
|
|
546
|
+
* transition(':increment, * => enabled, :enter', animate('1s ease', keyframes([
|
|
547
|
+
* style({ transform: 'scale(1)', offset: 0}),
|
|
548
|
+
* style({ transform: 'scale(1.1)', offset: 0.7}),
|
|
549
|
+
* style({ transform: 'scale(1)', offset: 1})
|
|
550
|
+
* ]))),
|
|
551
|
+
* ```
|
|
552
|
+
*
|
|
553
|
+
* Also note that in such context:
|
|
554
|
+
* - `void` can be used to indicate the absence of the element
|
|
555
|
+
* - asterisks can be used as wildcards that match any state
|
|
556
|
+
* - (as a consequence of the above, `void => *` is equivalent to `:enter` and `* => void` is
|
|
557
|
+
* equivalent to `:leave`)
|
|
558
|
+
* - `true` and `false` also match expression values of `1` and `0` respectively (but do not match
|
|
559
|
+
* _truthy_ and _falsy_ values)
|
|
565
560
|
*
|
|
566
|
-
*
|
|
561
|
+
* <div class="alert is-helpful">
|
|
567
562
|
*
|
|
568
|
-
*
|
|
563
|
+
* Be careful about entering end leaving elements as their transitions present a common
|
|
564
|
+
* pitfall for developers.
|
|
569
565
|
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* transition(":leave", [
|
|
576
|
-
* animate(500, style({ opacity: 0 }))
|
|
577
|
-
* ])
|
|
578
|
-
* ```
|
|
566
|
+
* Note that when an element with a trigger enters the DOM its `:enter` transition always
|
|
567
|
+
* gets executed, but its `:leave` transition will not be executed if the element is removed
|
|
568
|
+
* alongside its parent (as it will be removed "without warning" before its transition has
|
|
569
|
+
* a chance to be executed, the only way that such transition can occur is if the element
|
|
570
|
+
* is exiting the DOM on its own).
|
|
579
571
|
*
|
|
580
|
-
* - Use `:increment` and `:decrement` to initiate transitions:
|
|
581
572
|
*
|
|
582
|
-
*
|
|
583
|
-
* transition(":increment", group([
|
|
584
|
-
* query(':enter', [
|
|
585
|
-
* style({ left: '100%' }),
|
|
586
|
-
* animate('0.5s ease-out', style('*'))
|
|
587
|
-
* ]),
|
|
588
|
-
* query(':leave', [
|
|
589
|
-
* animate('0.5s ease-out', style({ left: '-100%' }))
|
|
590
|
-
* ])
|
|
591
|
-
* ]))
|
|
573
|
+
* </div>
|
|
592
574
|
*
|
|
593
|
-
*
|
|
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
|
-
* ```
|
|
575
|
+
* ### Animating to a Final State
|
|
603
576
|
*
|
|
604
|
-
*
|
|
577
|
+
* If the final step in a transition is a call to `animate()` that uses a timing value
|
|
578
|
+
* with no `style` data, that step is automatically considered the final animation arc,
|
|
579
|
+
* for the element to reach the final state, in such case Angular automatically adds or removes
|
|
580
|
+
* CSS styles to ensure that the element is in the correct final state.
|
|
605
581
|
*
|
|
606
|
-
* Here is an example of a `fromState` specified as a state-change function that invokes an
|
|
607
|
-
* animation when true:
|
|
608
582
|
*
|
|
609
|
-
*
|
|
610
|
-
* transition((fromState, toState) =>
|
|
611
|
-
* {
|
|
612
|
-
* return fromState == "off" && toState == "on";
|
|
613
|
-
* },
|
|
614
|
-
* animate("1s 0s"))
|
|
615
|
-
* ```
|
|
583
|
+
* ### Usage Examples
|
|
616
584
|
*
|
|
617
|
-
*
|
|
585
|
+
* - Transition animations applied based on
|
|
586
|
+
* the trigger's expression value
|
|
618
587
|
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
*
|
|
588
|
+
* ```HTML
|
|
589
|
+
* <div [@myAnimationTrigger]="myStatusExp">
|
|
590
|
+
* ...
|
|
591
|
+
* </div>
|
|
592
|
+
* ```
|
|
623
593
|
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
594
|
+
* ```typescript
|
|
595
|
+
* trigger("myAnimationTrigger", [
|
|
596
|
+
* ..., // states
|
|
597
|
+
* transition("on => off, open => closed", animate(500)),
|
|
598
|
+
* transition("* <=> error", query('.indicator', animateChild()))
|
|
599
|
+
* ])
|
|
600
|
+
* ```
|
|
626
601
|
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
* style({ opacity: 0 }),
|
|
630
|
-
* animate(500)
|
|
631
|
-
* ])
|
|
632
|
-
* ```
|
|
633
|
-
* ### Boolean value matching
|
|
634
|
-
* If a trigger binding value is a Boolean, it can be matched using a transition expression
|
|
635
|
-
* that compares true and false or 1 and 0. For example:
|
|
602
|
+
* - Transition animations applied based on custom logic dependent
|
|
603
|
+
* on the trigger's expression value and provided parameters
|
|
636
604
|
*
|
|
637
|
-
*
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
605
|
+
* ```HTML
|
|
606
|
+
* <div [@myAnimationTrigger]="{
|
|
607
|
+
* value: stepName,
|
|
608
|
+
* params: { target: currentTarget }
|
|
609
|
+
* }">
|
|
610
|
+
* ...
|
|
611
|
+
* </div>
|
|
612
|
+
* ```
|
|
613
|
+
*
|
|
614
|
+
* ```typescript
|
|
615
|
+
* trigger("myAnimationTrigger", [
|
|
616
|
+
* ..., // states
|
|
617
|
+
* transition(
|
|
618
|
+
* (fromState, toState, _element, params) =>
|
|
619
|
+
* ['firststep', 'laststep'].includes(fromState.toLowerCase())
|
|
620
|
+
* && toState === params?.['target'],
|
|
621
|
+
* animate('1s')
|
|
622
|
+
* )
|
|
623
|
+
* ])
|
|
624
|
+
* ```
|
|
647
625
|
*
|
|
648
626
|
* @publicApi
|
|
649
627
|
**/
|