@angular/animations 13.2.0-rc.1 → 13.2.3
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 +10 -2
- package/browser/browser.d.ts +8 -71
- package/browser/testing/testing.d.ts +1 -1
- package/esm2020/browser/src/dsl/animation.mjs +4 -5
- package/esm2020/browser/src/dsl/animation_ast_builder.mjs +13 -14
- package/esm2020/browser/src/dsl/animation_timeline_builder.mjs +3 -2
- package/esm2020/browser/src/dsl/animation_transition_expr.mjs +4 -3
- package/esm2020/browser/src/dsl/animation_transition_factory.mjs +1 -1
- package/esm2020/browser/src/dsl/animation_transition_instruction.mjs +1 -1
- package/esm2020/browser/src/dsl/animation_trigger.mjs +1 -1
- package/esm2020/browser/src/dsl/style_normalization/animation_style_normalizer.mjs +1 -1
- package/esm2020/browser/src/dsl/style_normalization/web_animations_style_normalizer.mjs +3 -2
- package/esm2020/browser/src/error_helpers.mjs +135 -0
- package/esm2020/browser/src/errors.mjs +9 -0
- package/esm2020/browser/src/private_export.mjs +2 -4
- package/esm2020/browser/src/render/animation_driver.mjs +3 -3
- package/esm2020/browser/src/render/animation_engine_next.mjs +3 -2
- package/esm2020/browser/src/render/shared.mjs +3 -3
- package/esm2020/browser/src/render/timeline_animation_engine.mjs +6 -5
- package/esm2020/browser/src/render/transition_animation_engine.mjs +8 -8
- package/esm2020/browser/src/render/web_animations/web_animations_driver.mjs +3 -21
- package/esm2020/browser/src/util.mjs +9 -8
- package/esm2020/src/animation_metadata.mjs +10 -2
- package/esm2020/src/version.mjs +1 -1
- package/fesm2015/animations.mjs +10 -2
- package/fesm2015/animations.mjs.map +1 -1
- package/fesm2015/browser/testing.mjs +1 -1
- package/fesm2015/browser.mjs +179 -502
- package/fesm2015/browser.mjs.map +1 -1
- package/fesm2020/animations.mjs +10 -2
- package/fesm2020/animations.mjs.map +1 -1
- package/fesm2020/browser/testing.mjs +1 -1
- package/fesm2020/browser.mjs +179 -501
- package/fesm2020/browser.mjs.map +1 -1
- package/package.json +2 -2
- package/esm2020/browser/src/render/css_keyframes/css_keyframes_driver.mjs +0 -121
- package/esm2020/browser/src/render/css_keyframes/css_keyframes_player.mjs +0 -133
- package/esm2020/browser/src/render/css_keyframes/direct_style_player.mjs +0 -51
- package/esm2020/browser/src/render/css_keyframes/element_animation_style_handler.mjs +0 -137
package/fesm2015/browser.mjs
CHANGED
|
@@ -1,12 +1,146 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v13.2.
|
|
2
|
+
* @license Angular v13.2.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ɵAnimationGroupPlayer, NoopAnimationPlayer, AUTO_STYLE, ɵPRE_STYLE, sequence, style } from '@angular/animations';
|
|
8
8
|
import * as i0 from '@angular/core';
|
|
9
|
-
import { Injectable } from '@angular/core';
|
|
9
|
+
import { ɵRuntimeError, Injectable } from '@angular/core';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright Google LLC All Rights Reserved.
|
|
14
|
+
*
|
|
15
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
16
|
+
* found in the LICENSE file at https://angular.io/license
|
|
17
|
+
*/
|
|
18
|
+
const NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
|
|
19
|
+
const LINE_START = '\n - ';
|
|
20
|
+
function invalidTimingValue(exp) {
|
|
21
|
+
return new ɵRuntimeError(3000 /* INVALID_TIMING_VALUE */, NG_DEV_MODE && `The provided timing value "${exp}" is invalid.`);
|
|
22
|
+
}
|
|
23
|
+
function negativeStepValue() {
|
|
24
|
+
return new ɵRuntimeError(3100 /* NEGATIVE_STEP_VALUE */, NG_DEV_MODE && 'Duration values below 0 are not allowed for this animation step.');
|
|
25
|
+
}
|
|
26
|
+
function negativeDelayValue() {
|
|
27
|
+
return new ɵRuntimeError(3101 /* NEGATIVE_DELAY_VALUE */, NG_DEV_MODE && 'Delay values below 0 are not allowed for this animation step.');
|
|
28
|
+
}
|
|
29
|
+
function invalidStyleParams(varName) {
|
|
30
|
+
return new ɵRuntimeError(3001 /* INVALID_STYLE_PARAMS */, NG_DEV_MODE &&
|
|
31
|
+
`Unable to resolve the local animation param ${varName} in the given list of values`);
|
|
32
|
+
}
|
|
33
|
+
function invalidParamValue(varName) {
|
|
34
|
+
return new ɵRuntimeError(3003 /* INVALID_PARAM_VALUE */, NG_DEV_MODE && `Please provide a value for the animation param ${varName}`);
|
|
35
|
+
}
|
|
36
|
+
function invalidNodeType(nodeType) {
|
|
37
|
+
return new ɵRuntimeError(3004 /* INVALID_NODE_TYPE */, NG_DEV_MODE && `Unable to resolve animation metadata node #${nodeType}`);
|
|
38
|
+
}
|
|
39
|
+
function invalidCssUnitValue(userProvidedProperty, value) {
|
|
40
|
+
return new ɵRuntimeError(3005 /* INVALID_CSS_UNIT_VALUE */, NG_DEV_MODE && `Please provide a CSS unit value for ${userProvidedProperty}:${value}`);
|
|
41
|
+
}
|
|
42
|
+
function invalidTrigger() {
|
|
43
|
+
return new ɵRuntimeError(3006 /* INVALID_TRIGGER */, NG_DEV_MODE &&
|
|
44
|
+
'animation triggers cannot be prefixed with an `@` sign (e.g. trigger(\'@foo\', [...]))');
|
|
45
|
+
}
|
|
46
|
+
function invalidDefinition() {
|
|
47
|
+
return new ɵRuntimeError(3007 /* INVALID_DEFINITION */, NG_DEV_MODE && 'only state() and transition() definitions can sit inside of a trigger()');
|
|
48
|
+
}
|
|
49
|
+
function invalidState(metadataName, missingSubs) {
|
|
50
|
+
return new ɵRuntimeError(3008 /* INVALID_STATE */, NG_DEV_MODE &&
|
|
51
|
+
`state("${metadataName}", ...) must define default values for all the following style substitutions: ${missingSubs.join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
function invalidStyleValue(value) {
|
|
54
|
+
return new ɵRuntimeError(3002 /* INVALID_STYLE_VALUE */, NG_DEV_MODE && `The provided style string value ${value} is not allowed.`);
|
|
55
|
+
}
|
|
56
|
+
function invalidProperty(prop) {
|
|
57
|
+
return new ɵRuntimeError(3009 /* INVALID_PROPERTY */, NG_DEV_MODE &&
|
|
58
|
+
`The provided animation property "${prop}" is not a supported CSS property for animations`);
|
|
59
|
+
}
|
|
60
|
+
function invalidParallelAnimation(prop, firstStart, firstEnd, secondStart, secondEnd) {
|
|
61
|
+
return new ɵRuntimeError(3010 /* INVALID_PARALLEL_ANIMATION */, NG_DEV_MODE &&
|
|
62
|
+
`The CSS property "${prop}" that exists between the times of "${firstStart}ms" and "${firstEnd}ms" is also being animated in a parallel animation between the times of "${secondStart}ms" and "${secondEnd}ms"`);
|
|
63
|
+
}
|
|
64
|
+
function invalidKeyframes() {
|
|
65
|
+
return new ɵRuntimeError(3011 /* INVALID_KEYFRAMES */, NG_DEV_MODE && `keyframes() must be placed inside of a call to animate()`);
|
|
66
|
+
}
|
|
67
|
+
function invalidOffset() {
|
|
68
|
+
return new ɵRuntimeError(3012 /* INVALID_OFFSET */, NG_DEV_MODE && `Please ensure that all keyframe offsets are between 0 and 1`);
|
|
69
|
+
}
|
|
70
|
+
function keyframeOffsetsOutOfOrder() {
|
|
71
|
+
return new ɵRuntimeError(3200 /* KEYFRAME_OFFSETS_OUT_OF_ORDER */, NG_DEV_MODE && `Please ensure that all keyframe offsets are in order`);
|
|
72
|
+
}
|
|
73
|
+
function keyframesMissingOffsets() {
|
|
74
|
+
return new ɵRuntimeError(3202 /* KEYFRAMES_MISSING_OFFSETS */, NG_DEV_MODE && `Not all style() steps within the declared keyframes() contain offsets`);
|
|
75
|
+
}
|
|
76
|
+
function invalidStagger() {
|
|
77
|
+
return new ɵRuntimeError(3013 /* INVALID_STAGGER */, NG_DEV_MODE && `stagger() can only be used inside of query()`);
|
|
78
|
+
}
|
|
79
|
+
function invalidQuery(selector) {
|
|
80
|
+
return new ɵRuntimeError(3014 /* INVALID_QUERY */, NG_DEV_MODE &&
|
|
81
|
+
`\`query("${selector}")\` returned zero elements. (Use \`query("${selector}", { optional: true })\` if you wish to allow this.)`);
|
|
82
|
+
}
|
|
83
|
+
function invalidExpression(expr) {
|
|
84
|
+
return new ɵRuntimeError(3015 /* INVALID_EXPRESSION */, NG_DEV_MODE && `The provided transition expression "${expr}" is not supported`);
|
|
85
|
+
}
|
|
86
|
+
function invalidTransitionAlias(alias) {
|
|
87
|
+
return new ɵRuntimeError(3016 /* INVALID_TRANSITION_ALIAS */, NG_DEV_MODE && `The transition alias value "${alias}" is not supported`);
|
|
88
|
+
}
|
|
89
|
+
function validationFailed(errors) {
|
|
90
|
+
return new ɵRuntimeError(3500 /* VALIDATION_FAILED */, NG_DEV_MODE && `animation validation failed:\n${errors.map(err => err.message).join('\n')}`);
|
|
91
|
+
}
|
|
92
|
+
function buildingFailed(errors) {
|
|
93
|
+
return new ɵRuntimeError(3501 /* BUILDING_FAILED */, NG_DEV_MODE && `animation building failed:\n${errors.map(err => err.message).join('\n')}`);
|
|
94
|
+
}
|
|
95
|
+
function triggerBuildFailed(name, errors) {
|
|
96
|
+
return new ɵRuntimeError(3404 /* TRIGGER_BUILD_FAILED */, NG_DEV_MODE &&
|
|
97
|
+
`The animation trigger "${name}" has failed to build due to the following errors:\n - ${errors.map(err => err.message).join('\n - ')}`);
|
|
98
|
+
}
|
|
99
|
+
function animationFailed(errors) {
|
|
100
|
+
return new ɵRuntimeError(3502 /* ANIMATION_FAILED */, NG_DEV_MODE &&
|
|
101
|
+
`Unable to animate due to the following errors:${LINE_START}${errors.map(err => err.message).join(LINE_START)}`);
|
|
102
|
+
}
|
|
103
|
+
function registerFailed(errors) {
|
|
104
|
+
return new ɵRuntimeError(3503 /* REGISTRATION_FAILED */, NG_DEV_MODE &&
|
|
105
|
+
`Unable to build the animation due to the following errors: ${errors.map(err => err.message).join('\n')}`);
|
|
106
|
+
}
|
|
107
|
+
function missingOrDestroyedAnimation() {
|
|
108
|
+
return new ɵRuntimeError(3300 /* MISSING_OR_DESTROYED_ANIMATION */, NG_DEV_MODE && 'The requested animation doesn\'t exist or has already been destroyed');
|
|
109
|
+
}
|
|
110
|
+
function createAnimationFailed(errors) {
|
|
111
|
+
return new ɵRuntimeError(3504 /* CREATE_ANIMATION_FAILED */, NG_DEV_MODE &&
|
|
112
|
+
`Unable to create the animation due to the following errors:${errors.map(err => err.message).join('\n')}`);
|
|
113
|
+
}
|
|
114
|
+
function missingPlayer(id) {
|
|
115
|
+
return new ɵRuntimeError(3301 /* MISSING_PLAYER */, NG_DEV_MODE && `Unable to find the timeline player referenced by ${id}`);
|
|
116
|
+
}
|
|
117
|
+
function missingTrigger(phase, name) {
|
|
118
|
+
return new ɵRuntimeError(3302 /* MISSING_TRIGGER */, NG_DEV_MODE &&
|
|
119
|
+
`Unable to listen on the animation trigger event "${phase}" because the animation trigger "${name}" doesn\'t exist!`);
|
|
120
|
+
}
|
|
121
|
+
function missingEvent(name) {
|
|
122
|
+
return new ɵRuntimeError(3303 /* MISSING_EVENT */, NG_DEV_MODE &&
|
|
123
|
+
`Unable to listen on the animation trigger "${name}" because the provided event is undefined!`);
|
|
124
|
+
}
|
|
125
|
+
function unsupportedTriggerEvent(phase, name) {
|
|
126
|
+
return new ɵRuntimeError(3400 /* UNSUPPORTED_TRIGGER_EVENT */, NG_DEV_MODE &&
|
|
127
|
+
`The provided animation trigger event "${phase}" for the animation trigger "${name}" is not supported!`);
|
|
128
|
+
}
|
|
129
|
+
function unregisteredTrigger(name) {
|
|
130
|
+
return new ɵRuntimeError(3401 /* UNREGISTERED_TRIGGER */, NG_DEV_MODE && `The provided animation trigger "${name}" has not been registered!`);
|
|
131
|
+
}
|
|
132
|
+
function triggerTransitionsFailed(errors) {
|
|
133
|
+
return new ɵRuntimeError(3402 /* TRIGGER_TRANSITIONS_FAILED */, NG_DEV_MODE &&
|
|
134
|
+
`Unable to process animations due to the following failed trigger transitions\n ${errors.map(err => err.message).join('\n')}`);
|
|
135
|
+
}
|
|
136
|
+
function triggerParsingFailed(name, errors) {
|
|
137
|
+
return new ɵRuntimeError(3403 /* TRIGGER_PARSING_FAILED */, NG_DEV_MODE &&
|
|
138
|
+
`Animation parsing for the ${name} trigger have failed:${LINE_START}${errors.map(err => err.message).join(LINE_START)}`);
|
|
139
|
+
}
|
|
140
|
+
function transitionFailed(name, errors) {
|
|
141
|
+
return new ɵRuntimeError(3505 /* TRANSITION_FAILED */, NG_DEV_MODE &&
|
|
142
|
+
`@${name} has failed due to:\n ${errors.map(err => err.message).join('\n- ')}`);
|
|
143
|
+
}
|
|
10
144
|
|
|
11
145
|
/**
|
|
12
146
|
* @license
|
|
@@ -72,8 +206,7 @@ function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles =
|
|
|
72
206
|
previousOffset = offset;
|
|
73
207
|
});
|
|
74
208
|
if (errors.length) {
|
|
75
|
-
|
|
76
|
-
throw new Error(`Unable to animate due to the following errors:${LINE_START}${errors.join(LINE_START)}`);
|
|
209
|
+
throw animationFailed(errors);
|
|
77
210
|
}
|
|
78
211
|
return normalizedKeyframes;
|
|
79
212
|
}
|
|
@@ -225,9 +358,9 @@ class NoopAnimationDriver {
|
|
|
225
358
|
return new NoopAnimationPlayer(duration, delay);
|
|
226
359
|
}
|
|
227
360
|
}
|
|
228
|
-
NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.
|
|
229
|
-
NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.
|
|
230
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.
|
|
361
|
+
NoopAnimationDriver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
362
|
+
NoopAnimationDriver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: NoopAnimationDriver });
|
|
363
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: NoopAnimationDriver, decorators: [{
|
|
231
364
|
type: Injectable
|
|
232
365
|
}] });
|
|
233
366
|
/**
|
|
@@ -244,7 +377,7 @@ AnimationDriver.NOOP = ( /* @__PURE__ */new NoopAnimationDriver());
|
|
|
244
377
|
* Use of this source code is governed by an MIT-style license that can be
|
|
245
378
|
* found in the LICENSE file at https://angular.io/license
|
|
246
379
|
*/
|
|
247
|
-
const ONE_SECOND
|
|
380
|
+
const ONE_SECOND = 1000;
|
|
248
381
|
const SUBSTITUTION_EXPR_START = '{{';
|
|
249
382
|
const SUBSTITUTION_EXPR_END = '}}';
|
|
250
383
|
const ENTER_CLASSNAME = 'ng-enter';
|
|
@@ -264,7 +397,7 @@ function resolveTimingValue(value) {
|
|
|
264
397
|
function _convertTimeValueToMS(value, unit) {
|
|
265
398
|
switch (unit) {
|
|
266
399
|
case 's':
|
|
267
|
-
return value * ONE_SECOND
|
|
400
|
+
return value * ONE_SECOND;
|
|
268
401
|
default: // ms or something else
|
|
269
402
|
return value;
|
|
270
403
|
}
|
|
@@ -282,7 +415,7 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
|
|
|
282
415
|
if (typeof exp === 'string') {
|
|
283
416
|
const matches = exp.match(regex);
|
|
284
417
|
if (matches === null) {
|
|
285
|
-
errors.push(
|
|
418
|
+
errors.push(invalidTimingValue(exp));
|
|
286
419
|
return { duration: 0, delay: 0, easing: '' };
|
|
287
420
|
}
|
|
288
421
|
duration = _convertTimeValueToMS(parseFloat(matches[1]), matches[2]);
|
|
@@ -302,15 +435,15 @@ function parseTimeExpression(exp, errors, allowNegativeValues) {
|
|
|
302
435
|
let containsErrors = false;
|
|
303
436
|
let startIndex = errors.length;
|
|
304
437
|
if (duration < 0) {
|
|
305
|
-
errors.push(
|
|
438
|
+
errors.push(negativeStepValue());
|
|
306
439
|
containsErrors = true;
|
|
307
440
|
}
|
|
308
441
|
if (delay < 0) {
|
|
309
|
-
errors.push(
|
|
442
|
+
errors.push(negativeDelayValue());
|
|
310
443
|
containsErrors = true;
|
|
311
444
|
}
|
|
312
445
|
if (containsErrors) {
|
|
313
|
-
errors.splice(startIndex, 0,
|
|
446
|
+
errors.splice(startIndex, 0, invalidTimingValue(exp));
|
|
314
447
|
}
|
|
315
448
|
}
|
|
316
449
|
return { duration, delay, easing };
|
|
@@ -416,7 +549,7 @@ function validateStyleParams(value, options, errors) {
|
|
|
416
549
|
if (matches.length) {
|
|
417
550
|
matches.forEach(varName => {
|
|
418
551
|
if (!params.hasOwnProperty(varName)) {
|
|
419
|
-
errors.push(
|
|
552
|
+
errors.push(invalidStyleParams(varName));
|
|
420
553
|
}
|
|
421
554
|
});
|
|
422
555
|
}
|
|
@@ -439,7 +572,7 @@ function interpolateParams(value, params, errors) {
|
|
|
439
572
|
let localVal = params[varName];
|
|
440
573
|
// this means that the value was never overridden by the data passed in by the user
|
|
441
574
|
if (!params.hasOwnProperty(varName)) {
|
|
442
|
-
errors.push(
|
|
575
|
+
errors.push(invalidParamValue(varName));
|
|
443
576
|
localVal = '';
|
|
444
577
|
}
|
|
445
578
|
return localVal.toString();
|
|
@@ -518,7 +651,7 @@ function visitDslNode(visitor, node, context) {
|
|
|
518
651
|
case 12 /* Stagger */:
|
|
519
652
|
return visitor.visitStagger(node, context);
|
|
520
653
|
default:
|
|
521
|
-
throw
|
|
654
|
+
throw invalidNodeType(node.type);
|
|
522
655
|
}
|
|
523
656
|
}
|
|
524
657
|
function computeStyle(element, prop) {
|
|
@@ -554,7 +687,7 @@ function parseInnerTransitionStr(eventStr, expressions, errors) {
|
|
|
554
687
|
}
|
|
555
688
|
const match = eventStr.match(/^(\*|[-\w]+)\s*(<?[=-]>)\s*(\*|[-\w]+)$/);
|
|
556
689
|
if (match == null || match.length < 4) {
|
|
557
|
-
errors.push(
|
|
690
|
+
errors.push(invalidExpression(eventStr));
|
|
558
691
|
return expressions;
|
|
559
692
|
}
|
|
560
693
|
const fromState = match[1];
|
|
@@ -577,7 +710,7 @@ function parseAnimationAlias(alias, errors) {
|
|
|
577
710
|
case ':decrement':
|
|
578
711
|
return (fromState, toState) => parseFloat(toState) < parseFloat(fromState);
|
|
579
712
|
default:
|
|
580
|
-
errors.push(
|
|
713
|
+
errors.push(invalidTransitionAlias(alias));
|
|
581
714
|
return '* => *';
|
|
582
715
|
}
|
|
583
716
|
}
|
|
@@ -673,7 +806,7 @@ class AnimationAstBuilderVisitor {
|
|
|
673
806
|
const states = [];
|
|
674
807
|
const transitions = [];
|
|
675
808
|
if (metadata.name.charAt(0) == '@') {
|
|
676
|
-
context.errors.push(
|
|
809
|
+
context.errors.push(invalidTrigger());
|
|
677
810
|
}
|
|
678
811
|
metadata.definitions.forEach(def => {
|
|
679
812
|
this._resetContextStyleTimingState(context);
|
|
@@ -693,7 +826,7 @@ class AnimationAstBuilderVisitor {
|
|
|
693
826
|
transitions.push(transition);
|
|
694
827
|
}
|
|
695
828
|
else {
|
|
696
|
-
context.errors.push(
|
|
829
|
+
context.errors.push(invalidDefinition());
|
|
697
830
|
}
|
|
698
831
|
});
|
|
699
832
|
return {
|
|
@@ -726,8 +859,7 @@ class AnimationAstBuilderVisitor {
|
|
|
726
859
|
});
|
|
727
860
|
if (missingSubs.size) {
|
|
728
861
|
const missingSubsArr = iteratorToArray(missingSubs.values());
|
|
729
|
-
context.errors.push(
|
|
730
|
-
.name}", ...) must define default values for all the following style substitutions: ${missingSubsArr.join(', ')}`);
|
|
862
|
+
context.errors.push(invalidState(metadata.name, missingSubsArr));
|
|
731
863
|
}
|
|
732
864
|
}
|
|
733
865
|
return {
|
|
@@ -820,7 +952,7 @@ class AnimationAstBuilderVisitor {
|
|
|
820
952
|
styles.push(styleTuple);
|
|
821
953
|
}
|
|
822
954
|
else {
|
|
823
|
-
context.errors.push(
|
|
955
|
+
context.errors.push(invalidStyleValue(styleTuple));
|
|
824
956
|
}
|
|
825
957
|
}
|
|
826
958
|
else {
|
|
@@ -873,7 +1005,7 @@ class AnimationAstBuilderVisitor {
|
|
|
873
1005
|
return;
|
|
874
1006
|
Object.keys(tuple).forEach(prop => {
|
|
875
1007
|
if (!this._driver.validateStyleProperty(prop)) {
|
|
876
|
-
context.errors.push(
|
|
1008
|
+
context.errors.push(invalidProperty(prop));
|
|
877
1009
|
return;
|
|
878
1010
|
}
|
|
879
1011
|
const collectedStyles = context.collectedStyles[context.currentQuerySelector];
|
|
@@ -882,8 +1014,7 @@ class AnimationAstBuilderVisitor {
|
|
|
882
1014
|
if (collectedEntry) {
|
|
883
1015
|
if (startTime != endTime && startTime >= collectedEntry.startTime &&
|
|
884
1016
|
endTime <= collectedEntry.endTime) {
|
|
885
|
-
context.errors.push(
|
|
886
|
-
.endTime}ms" is also being animated in a parallel animation between the times of "${startTime}ms" and "${endTime}ms"`);
|
|
1017
|
+
context.errors.push(invalidParallelAnimation(prop, collectedEntry.startTime, collectedEntry.endTime, startTime, endTime));
|
|
887
1018
|
updateCollectedStyle = false;
|
|
888
1019
|
}
|
|
889
1020
|
// we always choose the smaller start time value since we
|
|
@@ -903,7 +1034,7 @@ class AnimationAstBuilderVisitor {
|
|
|
903
1034
|
visitKeyframes(metadata, context) {
|
|
904
1035
|
const ast = { type: 5 /* Keyframes */, styles: [], options: null };
|
|
905
1036
|
if (!context.currentAnimateTimings) {
|
|
906
|
-
context.errors.push(
|
|
1037
|
+
context.errors.push(invalidKeyframes());
|
|
907
1038
|
return ast;
|
|
908
1039
|
}
|
|
909
1040
|
const MAX_KEYFRAME_OFFSET = 1;
|
|
@@ -927,15 +1058,15 @@ class AnimationAstBuilderVisitor {
|
|
|
927
1058
|
return style;
|
|
928
1059
|
});
|
|
929
1060
|
if (keyframesOutOfRange) {
|
|
930
|
-
context.errors.push(
|
|
1061
|
+
context.errors.push(invalidOffset());
|
|
931
1062
|
}
|
|
932
1063
|
if (offsetsOutOfOrder) {
|
|
933
|
-
context.errors.push(
|
|
1064
|
+
context.errors.push(keyframeOffsetsOutOfOrder());
|
|
934
1065
|
}
|
|
935
1066
|
const length = metadata.steps.length;
|
|
936
1067
|
let generatedOffset = 0;
|
|
937
1068
|
if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) {
|
|
938
|
-
context.errors.push(
|
|
1069
|
+
context.errors.push(keyframesMissingOffsets());
|
|
939
1070
|
}
|
|
940
1071
|
else if (totalKeyframesWithOffsets == 0) {
|
|
941
1072
|
generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1);
|
|
@@ -1001,7 +1132,7 @@ class AnimationAstBuilderVisitor {
|
|
|
1001
1132
|
}
|
|
1002
1133
|
visitStagger(metadata, context) {
|
|
1003
1134
|
if (!context.currentQuery) {
|
|
1004
|
-
context.errors.push(
|
|
1135
|
+
context.errors.push(invalidStagger());
|
|
1005
1136
|
}
|
|
1006
1137
|
const timings = metadata.timings === 'full' ?
|
|
1007
1138
|
{ duration: 0, delay: 0, easing: 'full' } :
|
|
@@ -1624,7 +1755,7 @@ class AnimationTimelineContext {
|
|
|
1624
1755
|
results.push(...elements);
|
|
1625
1756
|
}
|
|
1626
1757
|
if (!optional && results.length == 0) {
|
|
1627
|
-
errors.push(
|
|
1758
|
+
errors.push(invalidQuery(originalSelector));
|
|
1628
1759
|
}
|
|
1629
1760
|
return results;
|
|
1630
1761
|
}
|
|
@@ -1912,8 +2043,7 @@ class Animation {
|
|
|
1912
2043
|
const errors = [];
|
|
1913
2044
|
const ast = buildAnimationAst(_driver, input, errors);
|
|
1914
2045
|
if (errors.length) {
|
|
1915
|
-
|
|
1916
|
-
throw new Error(errorMessage);
|
|
2046
|
+
throw validationFailed(errors);
|
|
1917
2047
|
}
|
|
1918
2048
|
this._animationAst = ast;
|
|
1919
2049
|
}
|
|
@@ -1926,8 +2056,7 @@ class Animation {
|
|
|
1926
2056
|
subInstructions = subInstructions || new ElementInstructionMap();
|
|
1927
2057
|
const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
|
|
1928
2058
|
if (errors.length) {
|
|
1929
|
-
|
|
1930
|
-
throw new Error(errorMessage);
|
|
2059
|
+
throw buildingFailed(errors);
|
|
1931
2060
|
}
|
|
1932
2061
|
return result;
|
|
1933
2062
|
}
|
|
@@ -1978,7 +2107,7 @@ class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
|
|
|
1978
2107
|
else {
|
|
1979
2108
|
const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
|
|
1980
2109
|
if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
|
|
1981
|
-
errors.push(
|
|
2110
|
+
errors.push(invalidCssUnitValue(userProvidedProperty, value));
|
|
1982
2111
|
}
|
|
1983
2112
|
}
|
|
1984
2113
|
}
|
|
@@ -2177,7 +2306,7 @@ class TimelineAnimationEngine {
|
|
|
2177
2306
|
const errors = [];
|
|
2178
2307
|
const ast = buildAnimationAst(this._driver, metadata, errors);
|
|
2179
2308
|
if (errors.length) {
|
|
2180
|
-
throw
|
|
2309
|
+
throw registerFailed(errors);
|
|
2181
2310
|
}
|
|
2182
2311
|
else {
|
|
2183
2312
|
this._animations[id] = ast;
|
|
@@ -2201,11 +2330,11 @@ class TimelineAnimationEngine {
|
|
|
2201
2330
|
});
|
|
2202
2331
|
}
|
|
2203
2332
|
else {
|
|
2204
|
-
errors.push(
|
|
2333
|
+
errors.push(missingOrDestroyedAnimation());
|
|
2205
2334
|
instructions = [];
|
|
2206
2335
|
}
|
|
2207
2336
|
if (errors.length) {
|
|
2208
|
-
throw
|
|
2337
|
+
throw createAnimationFailed(errors);
|
|
2209
2338
|
}
|
|
2210
2339
|
autoStylesMap.forEach((styles, element) => {
|
|
2211
2340
|
Object.keys(styles).forEach(prop => {
|
|
@@ -2234,7 +2363,7 @@ class TimelineAnimationEngine {
|
|
|
2234
2363
|
_getPlayer(id) {
|
|
2235
2364
|
const player = this._playersById[id];
|
|
2236
2365
|
if (!player) {
|
|
2237
|
-
throw
|
|
2366
|
+
throw missingPlayer(id);
|
|
2238
2367
|
}
|
|
2239
2368
|
return player;
|
|
2240
2369
|
}
|
|
@@ -2362,13 +2491,13 @@ class AnimationTransitionNamespace {
|
|
|
2362
2491
|
}
|
|
2363
2492
|
listen(element, name, phase, callback) {
|
|
2364
2493
|
if (!this._triggers.hasOwnProperty(name)) {
|
|
2365
|
-
throw
|
|
2494
|
+
throw missingTrigger(phase, name);
|
|
2366
2495
|
}
|
|
2367
2496
|
if (phase == null || phase.length == 0) {
|
|
2368
|
-
throw
|
|
2497
|
+
throw missingEvent(name);
|
|
2369
2498
|
}
|
|
2370
2499
|
if (!isTriggerEventValid(phase)) {
|
|
2371
|
-
throw
|
|
2500
|
+
throw unsupportedTriggerEvent(phase, name);
|
|
2372
2501
|
}
|
|
2373
2502
|
const listeners = getOrSetAsInMap(this._elementListeners, element, []);
|
|
2374
2503
|
const data = { name, phase, callback };
|
|
@@ -2407,7 +2536,7 @@ class AnimationTransitionNamespace {
|
|
|
2407
2536
|
_getTrigger(name) {
|
|
2408
2537
|
const trigger = this._triggers[name];
|
|
2409
2538
|
if (!trigger) {
|
|
2410
|
-
throw
|
|
2539
|
+
throw unregisteredTrigger(name);
|
|
2411
2540
|
}
|
|
2412
2541
|
return trigger;
|
|
2413
2542
|
}
|
|
@@ -3048,7 +3177,7 @@ class TransitionAnimationEngine {
|
|
|
3048
3177
|
}
|
|
3049
3178
|
}
|
|
3050
3179
|
reportError(errors) {
|
|
3051
|
-
throw
|
|
3180
|
+
throw triggerTransitionsFailed(errors);
|
|
3052
3181
|
}
|
|
3053
3182
|
_flushAnimations(cleanupFns, microtaskId) {
|
|
3054
3183
|
const subTimelines = new ElementInstructionMap();
|
|
@@ -3210,8 +3339,7 @@ class TransitionAnimationEngine {
|
|
|
3210
3339
|
if (erroneousTransitions.length) {
|
|
3211
3340
|
const errors = [];
|
|
3212
3341
|
erroneousTransitions.forEach(instruction => {
|
|
3213
|
-
errors.push(
|
|
3214
|
-
instruction.errors.forEach(error => errors.push(`- ${error}\n`));
|
|
3342
|
+
errors.push(transitionFailed(instruction.triggerName, instruction.errors));
|
|
3215
3343
|
});
|
|
3216
3344
|
allPlayers.forEach(player => player.destroy());
|
|
3217
3345
|
this.reportError(errors);
|
|
@@ -3828,7 +3956,7 @@ class AnimationEngine {
|
|
|
3828
3956
|
const errors = [];
|
|
3829
3957
|
const ast = buildAnimationAst(this._driver, metadata, errors);
|
|
3830
3958
|
if (errors.length) {
|
|
3831
|
-
throw
|
|
3959
|
+
throw triggerBuildFailed(name, errors);
|
|
3832
3960
|
}
|
|
3833
3961
|
trigger = buildTrigger(name, ast, this._normalizer);
|
|
3834
3962
|
this._triggerCache[cacheKey] = trigger;
|
|
@@ -3986,440 +4114,6 @@ function isNonAnimatableStyle(prop) {
|
|
|
3986
4114
|
return prop === 'display' || prop === 'position';
|
|
3987
4115
|
}
|
|
3988
4116
|
|
|
3989
|
-
/**
|
|
3990
|
-
* @license
|
|
3991
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3992
|
-
*
|
|
3993
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3994
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3995
|
-
*/
|
|
3996
|
-
const ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
|
|
3997
|
-
const ANIMATION_PROP = 'animation';
|
|
3998
|
-
const ANIMATIONEND_EVENT = 'animationend';
|
|
3999
|
-
const ONE_SECOND = 1000;
|
|
4000
|
-
class ElementAnimationStyleHandler {
|
|
4001
|
-
constructor(_element, _name, _duration, _delay, _easing, _fillMode, _onDoneFn) {
|
|
4002
|
-
this._element = _element;
|
|
4003
|
-
this._name = _name;
|
|
4004
|
-
this._duration = _duration;
|
|
4005
|
-
this._delay = _delay;
|
|
4006
|
-
this._easing = _easing;
|
|
4007
|
-
this._fillMode = _fillMode;
|
|
4008
|
-
this._onDoneFn = _onDoneFn;
|
|
4009
|
-
this._finished = false;
|
|
4010
|
-
this._destroyed = false;
|
|
4011
|
-
this._startTime = 0;
|
|
4012
|
-
this._position = 0;
|
|
4013
|
-
this._eventFn = (e) => this._handleCallback(e);
|
|
4014
|
-
}
|
|
4015
|
-
apply() {
|
|
4016
|
-
applyKeyframeAnimation(this._element, `${this._duration}ms ${this._easing} ${this._delay}ms 1 normal ${this._fillMode} ${this._name}`);
|
|
4017
|
-
addRemoveAnimationEvent(this._element, this._eventFn, false);
|
|
4018
|
-
this._startTime = Date.now();
|
|
4019
|
-
}
|
|
4020
|
-
pause() {
|
|
4021
|
-
playPauseAnimation(this._element, this._name, 'paused');
|
|
4022
|
-
}
|
|
4023
|
-
resume() {
|
|
4024
|
-
playPauseAnimation(this._element, this._name, 'running');
|
|
4025
|
-
}
|
|
4026
|
-
setPosition(position) {
|
|
4027
|
-
const index = findIndexForAnimation(this._element, this._name);
|
|
4028
|
-
this._position = position * this._duration;
|
|
4029
|
-
setAnimationStyle(this._element, 'Delay', `-${this._position}ms`, index);
|
|
4030
|
-
}
|
|
4031
|
-
getPosition() {
|
|
4032
|
-
return this._position;
|
|
4033
|
-
}
|
|
4034
|
-
_handleCallback(event) {
|
|
4035
|
-
const timestamp = event._ngTestManualTimestamp || Date.now();
|
|
4036
|
-
const elapsedTime = parseFloat(event.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES)) * ONE_SECOND;
|
|
4037
|
-
if (event.animationName == this._name &&
|
|
4038
|
-
Math.max(timestamp - this._startTime, 0) >= this._delay && elapsedTime >= this._duration) {
|
|
4039
|
-
this.finish();
|
|
4040
|
-
}
|
|
4041
|
-
}
|
|
4042
|
-
finish() {
|
|
4043
|
-
if (this._finished)
|
|
4044
|
-
return;
|
|
4045
|
-
this._finished = true;
|
|
4046
|
-
this._onDoneFn();
|
|
4047
|
-
addRemoveAnimationEvent(this._element, this._eventFn, true);
|
|
4048
|
-
}
|
|
4049
|
-
destroy() {
|
|
4050
|
-
if (this._destroyed)
|
|
4051
|
-
return;
|
|
4052
|
-
this._destroyed = true;
|
|
4053
|
-
this.finish();
|
|
4054
|
-
removeKeyframeAnimation(this._element, this._name);
|
|
4055
|
-
}
|
|
4056
|
-
}
|
|
4057
|
-
function playPauseAnimation(element, name, status) {
|
|
4058
|
-
const index = findIndexForAnimation(element, name);
|
|
4059
|
-
setAnimationStyle(element, 'PlayState', status, index);
|
|
4060
|
-
}
|
|
4061
|
-
function applyKeyframeAnimation(element, value) {
|
|
4062
|
-
const anim = getAnimationStyle(element, '').trim();
|
|
4063
|
-
let index = 0;
|
|
4064
|
-
if (anim.length) {
|
|
4065
|
-
index = countChars(anim, ',') + 1;
|
|
4066
|
-
value = `${anim}, ${value}`;
|
|
4067
|
-
}
|
|
4068
|
-
setAnimationStyle(element, '', value);
|
|
4069
|
-
return index;
|
|
4070
|
-
}
|
|
4071
|
-
function removeKeyframeAnimation(element, name) {
|
|
4072
|
-
const anim = getAnimationStyle(element, '');
|
|
4073
|
-
const tokens = anim.split(',');
|
|
4074
|
-
const index = findMatchingTokenIndex(tokens, name);
|
|
4075
|
-
if (index >= 0) {
|
|
4076
|
-
tokens.splice(index, 1);
|
|
4077
|
-
const newValue = tokens.join(',');
|
|
4078
|
-
setAnimationStyle(element, '', newValue);
|
|
4079
|
-
}
|
|
4080
|
-
}
|
|
4081
|
-
function findIndexForAnimation(element, value) {
|
|
4082
|
-
const anim = getAnimationStyle(element, '');
|
|
4083
|
-
if (anim.indexOf(',') > 0) {
|
|
4084
|
-
const tokens = anim.split(',');
|
|
4085
|
-
return findMatchingTokenIndex(tokens, value);
|
|
4086
|
-
}
|
|
4087
|
-
return findMatchingTokenIndex([anim], value);
|
|
4088
|
-
}
|
|
4089
|
-
function findMatchingTokenIndex(tokens, searchToken) {
|
|
4090
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
4091
|
-
if (tokens[i].indexOf(searchToken) >= 0) {
|
|
4092
|
-
return i;
|
|
4093
|
-
}
|
|
4094
|
-
}
|
|
4095
|
-
return -1;
|
|
4096
|
-
}
|
|
4097
|
-
function addRemoveAnimationEvent(element, fn, doRemove) {
|
|
4098
|
-
doRemove ? element.removeEventListener(ANIMATIONEND_EVENT, fn) :
|
|
4099
|
-
element.addEventListener(ANIMATIONEND_EVENT, fn);
|
|
4100
|
-
}
|
|
4101
|
-
function setAnimationStyle(element, name, value, index) {
|
|
4102
|
-
const prop = ANIMATION_PROP + name;
|
|
4103
|
-
if (index != null) {
|
|
4104
|
-
const oldValue = element.style[prop];
|
|
4105
|
-
if (oldValue.length) {
|
|
4106
|
-
const tokens = oldValue.split(',');
|
|
4107
|
-
tokens[index] = value;
|
|
4108
|
-
value = tokens.join(',');
|
|
4109
|
-
}
|
|
4110
|
-
}
|
|
4111
|
-
element.style[prop] = value;
|
|
4112
|
-
}
|
|
4113
|
-
function getAnimationStyle(element, name) {
|
|
4114
|
-
return element.style[ANIMATION_PROP + name] || '';
|
|
4115
|
-
}
|
|
4116
|
-
function countChars(value, char) {
|
|
4117
|
-
let count = 0;
|
|
4118
|
-
for (let i = 0; i < value.length; i++) {
|
|
4119
|
-
const c = value.charAt(i);
|
|
4120
|
-
if (c === char)
|
|
4121
|
-
count++;
|
|
4122
|
-
}
|
|
4123
|
-
return count;
|
|
4124
|
-
}
|
|
4125
|
-
|
|
4126
|
-
const DEFAULT_FILL_MODE = 'forwards';
|
|
4127
|
-
const DEFAULT_EASING = 'linear';
|
|
4128
|
-
class CssKeyframesPlayer {
|
|
4129
|
-
constructor(element, keyframes, animationName, _duration, _delay, easing, _finalStyles, _specialStyles) {
|
|
4130
|
-
this.element = element;
|
|
4131
|
-
this.keyframes = keyframes;
|
|
4132
|
-
this.animationName = animationName;
|
|
4133
|
-
this._duration = _duration;
|
|
4134
|
-
this._delay = _delay;
|
|
4135
|
-
this._finalStyles = _finalStyles;
|
|
4136
|
-
this._specialStyles = _specialStyles;
|
|
4137
|
-
this._onDoneFns = [];
|
|
4138
|
-
this._onStartFns = [];
|
|
4139
|
-
this._onDestroyFns = [];
|
|
4140
|
-
this.currentSnapshot = {};
|
|
4141
|
-
this._state = 0;
|
|
4142
|
-
this.easing = easing || DEFAULT_EASING;
|
|
4143
|
-
this.totalTime = _duration + _delay;
|
|
4144
|
-
this._buildStyler();
|
|
4145
|
-
}
|
|
4146
|
-
onStart(fn) {
|
|
4147
|
-
this._onStartFns.push(fn);
|
|
4148
|
-
}
|
|
4149
|
-
onDone(fn) {
|
|
4150
|
-
this._onDoneFns.push(fn);
|
|
4151
|
-
}
|
|
4152
|
-
onDestroy(fn) {
|
|
4153
|
-
this._onDestroyFns.push(fn);
|
|
4154
|
-
}
|
|
4155
|
-
destroy() {
|
|
4156
|
-
this.init();
|
|
4157
|
-
if (this._state >= 4 /* DESTROYED */)
|
|
4158
|
-
return;
|
|
4159
|
-
this._state = 4 /* DESTROYED */;
|
|
4160
|
-
this._styler.destroy();
|
|
4161
|
-
this._flushStartFns();
|
|
4162
|
-
this._flushDoneFns();
|
|
4163
|
-
if (this._specialStyles) {
|
|
4164
|
-
this._specialStyles.destroy();
|
|
4165
|
-
}
|
|
4166
|
-
this._onDestroyFns.forEach(fn => fn());
|
|
4167
|
-
this._onDestroyFns = [];
|
|
4168
|
-
}
|
|
4169
|
-
_flushDoneFns() {
|
|
4170
|
-
this._onDoneFns.forEach(fn => fn());
|
|
4171
|
-
this._onDoneFns = [];
|
|
4172
|
-
}
|
|
4173
|
-
_flushStartFns() {
|
|
4174
|
-
this._onStartFns.forEach(fn => fn());
|
|
4175
|
-
this._onStartFns = [];
|
|
4176
|
-
}
|
|
4177
|
-
finish() {
|
|
4178
|
-
this.init();
|
|
4179
|
-
if (this._state >= 3 /* FINISHED */)
|
|
4180
|
-
return;
|
|
4181
|
-
this._state = 3 /* FINISHED */;
|
|
4182
|
-
this._styler.finish();
|
|
4183
|
-
this._flushStartFns();
|
|
4184
|
-
if (this._specialStyles) {
|
|
4185
|
-
this._specialStyles.finish();
|
|
4186
|
-
}
|
|
4187
|
-
this._flushDoneFns();
|
|
4188
|
-
}
|
|
4189
|
-
setPosition(value) {
|
|
4190
|
-
this._styler.setPosition(value);
|
|
4191
|
-
}
|
|
4192
|
-
getPosition() {
|
|
4193
|
-
return this._styler.getPosition();
|
|
4194
|
-
}
|
|
4195
|
-
hasStarted() {
|
|
4196
|
-
return this._state >= 2 /* STARTED */;
|
|
4197
|
-
}
|
|
4198
|
-
init() {
|
|
4199
|
-
if (this._state >= 1 /* INITIALIZED */)
|
|
4200
|
-
return;
|
|
4201
|
-
this._state = 1 /* INITIALIZED */;
|
|
4202
|
-
const elm = this.element;
|
|
4203
|
-
this._styler.apply();
|
|
4204
|
-
if (this._delay) {
|
|
4205
|
-
this._styler.pause();
|
|
4206
|
-
}
|
|
4207
|
-
}
|
|
4208
|
-
play() {
|
|
4209
|
-
this.init();
|
|
4210
|
-
if (!this.hasStarted()) {
|
|
4211
|
-
this._flushStartFns();
|
|
4212
|
-
this._state = 2 /* STARTED */;
|
|
4213
|
-
if (this._specialStyles) {
|
|
4214
|
-
this._specialStyles.start();
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
this._styler.resume();
|
|
4218
|
-
}
|
|
4219
|
-
pause() {
|
|
4220
|
-
this.init();
|
|
4221
|
-
this._styler.pause();
|
|
4222
|
-
}
|
|
4223
|
-
restart() {
|
|
4224
|
-
this.reset();
|
|
4225
|
-
this.play();
|
|
4226
|
-
}
|
|
4227
|
-
reset() {
|
|
4228
|
-
this._state = 0 /* RESET */;
|
|
4229
|
-
this._styler.destroy();
|
|
4230
|
-
this._buildStyler();
|
|
4231
|
-
this._styler.apply();
|
|
4232
|
-
}
|
|
4233
|
-
_buildStyler() {
|
|
4234
|
-
this._styler = new ElementAnimationStyleHandler(this.element, this.animationName, this._duration, this._delay, this.easing, DEFAULT_FILL_MODE, () => this.finish());
|
|
4235
|
-
}
|
|
4236
|
-
/** @internal */
|
|
4237
|
-
triggerCallback(phaseName) {
|
|
4238
|
-
const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
|
|
4239
|
-
methods.forEach(fn => fn());
|
|
4240
|
-
methods.length = 0;
|
|
4241
|
-
}
|
|
4242
|
-
beforeDestroy() {
|
|
4243
|
-
this.init();
|
|
4244
|
-
const styles = {};
|
|
4245
|
-
if (this.hasStarted()) {
|
|
4246
|
-
const finished = this._state >= 3 /* FINISHED */;
|
|
4247
|
-
Object.keys(this._finalStyles).forEach(prop => {
|
|
4248
|
-
if (prop != 'offset') {
|
|
4249
|
-
styles[prop] = finished ? this._finalStyles[prop] : computeStyle(this.element, prop);
|
|
4250
|
-
}
|
|
4251
|
-
});
|
|
4252
|
-
}
|
|
4253
|
-
this.currentSnapshot = styles;
|
|
4254
|
-
}
|
|
4255
|
-
}
|
|
4256
|
-
|
|
4257
|
-
/**
|
|
4258
|
-
* @license
|
|
4259
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4260
|
-
*
|
|
4261
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
4262
|
-
* found in the LICENSE file at https://angular.io/license
|
|
4263
|
-
*/
|
|
4264
|
-
class DirectStylePlayer extends NoopAnimationPlayer {
|
|
4265
|
-
constructor(element, styles) {
|
|
4266
|
-
super();
|
|
4267
|
-
this.element = element;
|
|
4268
|
-
this._startingStyles = {};
|
|
4269
|
-
this.__initialized = false;
|
|
4270
|
-
this._styles = hypenatePropsObject(styles);
|
|
4271
|
-
}
|
|
4272
|
-
init() {
|
|
4273
|
-
if (this.__initialized || !this._startingStyles)
|
|
4274
|
-
return;
|
|
4275
|
-
this.__initialized = true;
|
|
4276
|
-
Object.keys(this._styles).forEach(prop => {
|
|
4277
|
-
this._startingStyles[prop] = this.element.style[prop];
|
|
4278
|
-
});
|
|
4279
|
-
super.init();
|
|
4280
|
-
}
|
|
4281
|
-
play() {
|
|
4282
|
-
if (!this._startingStyles)
|
|
4283
|
-
return;
|
|
4284
|
-
this.init();
|
|
4285
|
-
Object.keys(this._styles)
|
|
4286
|
-
.forEach(prop => this.element.style.setProperty(prop, this._styles[prop]));
|
|
4287
|
-
super.play();
|
|
4288
|
-
}
|
|
4289
|
-
destroy() {
|
|
4290
|
-
if (!this._startingStyles)
|
|
4291
|
-
return;
|
|
4292
|
-
Object.keys(this._startingStyles).forEach(prop => {
|
|
4293
|
-
const value = this._startingStyles[prop];
|
|
4294
|
-
if (value) {
|
|
4295
|
-
this.element.style.setProperty(prop, value);
|
|
4296
|
-
}
|
|
4297
|
-
else {
|
|
4298
|
-
this.element.style.removeProperty(prop);
|
|
4299
|
-
}
|
|
4300
|
-
});
|
|
4301
|
-
this._startingStyles = null;
|
|
4302
|
-
super.destroy();
|
|
4303
|
-
}
|
|
4304
|
-
}
|
|
4305
|
-
|
|
4306
|
-
const KEYFRAMES_NAME_PREFIX = 'gen_css_kf_';
|
|
4307
|
-
const TAB_SPACE = ' ';
|
|
4308
|
-
class CssKeyframesDriver {
|
|
4309
|
-
constructor() {
|
|
4310
|
-
this._count = 0;
|
|
4311
|
-
}
|
|
4312
|
-
validateStyleProperty(prop) {
|
|
4313
|
-
return validateStyleProperty(prop);
|
|
4314
|
-
}
|
|
4315
|
-
matchesElement(_element, _selector) {
|
|
4316
|
-
// This method is deprecated and no longer in use so we return false.
|
|
4317
|
-
return false;
|
|
4318
|
-
}
|
|
4319
|
-
containsElement(elm1, elm2) {
|
|
4320
|
-
return containsElement(elm1, elm2);
|
|
4321
|
-
}
|
|
4322
|
-
query(element, selector, multi) {
|
|
4323
|
-
return invokeQuery(element, selector, multi);
|
|
4324
|
-
}
|
|
4325
|
-
computeStyle(element, prop, defaultValue) {
|
|
4326
|
-
return window.getComputedStyle(element)[prop];
|
|
4327
|
-
}
|
|
4328
|
-
buildKeyframeElement(element, name, keyframes) {
|
|
4329
|
-
keyframes = keyframes.map(kf => hypenatePropsObject(kf));
|
|
4330
|
-
let keyframeStr = `@keyframes ${name} {\n`;
|
|
4331
|
-
let tab = '';
|
|
4332
|
-
keyframes.forEach(kf => {
|
|
4333
|
-
tab = TAB_SPACE;
|
|
4334
|
-
const offset = parseFloat(kf['offset']);
|
|
4335
|
-
keyframeStr += `${tab}${offset * 100}% {\n`;
|
|
4336
|
-
tab += TAB_SPACE;
|
|
4337
|
-
Object.keys(kf).forEach(prop => {
|
|
4338
|
-
const value = kf[prop];
|
|
4339
|
-
switch (prop) {
|
|
4340
|
-
case 'offset':
|
|
4341
|
-
return;
|
|
4342
|
-
case 'easing':
|
|
4343
|
-
if (value) {
|
|
4344
|
-
keyframeStr += `${tab}animation-timing-function: ${value};\n`;
|
|
4345
|
-
}
|
|
4346
|
-
return;
|
|
4347
|
-
default:
|
|
4348
|
-
keyframeStr += `${tab}${prop}: ${value};\n`;
|
|
4349
|
-
return;
|
|
4350
|
-
}
|
|
4351
|
-
});
|
|
4352
|
-
keyframeStr += `${tab}}\n`;
|
|
4353
|
-
});
|
|
4354
|
-
keyframeStr += `}\n`;
|
|
4355
|
-
const kfElm = document.createElement('style');
|
|
4356
|
-
kfElm.textContent = keyframeStr;
|
|
4357
|
-
return kfElm;
|
|
4358
|
-
}
|
|
4359
|
-
animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
|
|
4360
|
-
if ((typeof ngDevMode === 'undefined' || ngDevMode) && scrubberAccessRequested) {
|
|
4361
|
-
notifyFaultyScrubber();
|
|
4362
|
-
}
|
|
4363
|
-
const previousCssKeyframePlayers = previousPlayers.filter(player => player instanceof CssKeyframesPlayer);
|
|
4364
|
-
const previousStyles = {};
|
|
4365
|
-
if (allowPreviousPlayerStylesMerge(duration, delay)) {
|
|
4366
|
-
previousCssKeyframePlayers.forEach(player => {
|
|
4367
|
-
let styles = player.currentSnapshot;
|
|
4368
|
-
Object.keys(styles).forEach(prop => previousStyles[prop] = styles[prop]);
|
|
4369
|
-
});
|
|
4370
|
-
}
|
|
4371
|
-
keyframes = balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles);
|
|
4372
|
-
const finalStyles = flattenKeyframesIntoStyles(keyframes);
|
|
4373
|
-
// if there is no animation then there is no point in applying
|
|
4374
|
-
// styles and waiting for an event to get fired. This causes lag.
|
|
4375
|
-
// It's better to just directly apply the styles to the element
|
|
4376
|
-
// via the direct styling animation player.
|
|
4377
|
-
if (duration == 0) {
|
|
4378
|
-
return new DirectStylePlayer(element, finalStyles);
|
|
4379
|
-
}
|
|
4380
|
-
const animationName = `${KEYFRAMES_NAME_PREFIX}${this._count++}`;
|
|
4381
|
-
const kfElm = this.buildKeyframeElement(element, animationName, keyframes);
|
|
4382
|
-
const nodeToAppendKfElm = findNodeToAppendKeyframeElement(element);
|
|
4383
|
-
nodeToAppendKfElm.appendChild(kfElm);
|
|
4384
|
-
const specialStyles = packageNonAnimatableStyles(element, keyframes);
|
|
4385
|
-
const player = new CssKeyframesPlayer(element, keyframes, animationName, duration, delay, easing, finalStyles, specialStyles);
|
|
4386
|
-
player.onDestroy(() => removeElement(kfElm));
|
|
4387
|
-
return player;
|
|
4388
|
-
}
|
|
4389
|
-
}
|
|
4390
|
-
function findNodeToAppendKeyframeElement(element) {
|
|
4391
|
-
var _a;
|
|
4392
|
-
const rootNode = (_a = element.getRootNode) === null || _a === void 0 ? void 0 : _a.call(element);
|
|
4393
|
-
if (typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot) {
|
|
4394
|
-
return rootNode;
|
|
4395
|
-
}
|
|
4396
|
-
return document.head;
|
|
4397
|
-
}
|
|
4398
|
-
function flattenKeyframesIntoStyles(keyframes) {
|
|
4399
|
-
let flatKeyframes = {};
|
|
4400
|
-
if (keyframes) {
|
|
4401
|
-
const kfs = Array.isArray(keyframes) ? keyframes : [keyframes];
|
|
4402
|
-
kfs.forEach(kf => {
|
|
4403
|
-
Object.keys(kf).forEach(prop => {
|
|
4404
|
-
if (prop == 'offset' || prop == 'easing')
|
|
4405
|
-
return;
|
|
4406
|
-
flatKeyframes[prop] = kf[prop];
|
|
4407
|
-
});
|
|
4408
|
-
});
|
|
4409
|
-
}
|
|
4410
|
-
return flatKeyframes;
|
|
4411
|
-
}
|
|
4412
|
-
function removeElement(node) {
|
|
4413
|
-
node.parentNode.removeChild(node);
|
|
4414
|
-
}
|
|
4415
|
-
let warningIssued = false;
|
|
4416
|
-
function notifyFaultyScrubber() {
|
|
4417
|
-
if (warningIssued)
|
|
4418
|
-
return;
|
|
4419
|
-
console.warn('@angular/animations: please load the web-animations.js polyfill to allow programmatic access...\n', ' visit https://bit.ly/IWukam to learn more about using the web-animation-js polyfill.');
|
|
4420
|
-
warningIssued = true;
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4423
4117
|
class WebAnimationsPlayer {
|
|
4424
4118
|
constructor(element, keyframes, options, _specialStyles) {
|
|
4425
4119
|
this.element = element;
|
|
@@ -4575,10 +4269,6 @@ class WebAnimationsPlayer {
|
|
|
4575
4269
|
}
|
|
4576
4270
|
|
|
4577
4271
|
class WebAnimationsDriver {
|
|
4578
|
-
constructor() {
|
|
4579
|
-
this._isNativeImpl = /\{\s*\[native\s+code\]\s*\}/.test(getElementAnimateFn().toString());
|
|
4580
|
-
this._cssKeyframesDriver = new CssKeyframesDriver();
|
|
4581
|
-
}
|
|
4582
4272
|
validateStyleProperty(prop) {
|
|
4583
4273
|
return validateStyleProperty(prop);
|
|
4584
4274
|
}
|
|
@@ -4595,14 +4285,7 @@ class WebAnimationsDriver {
|
|
|
4595
4285
|
computeStyle(element, prop, defaultValue) {
|
|
4596
4286
|
return window.getComputedStyle(element)[prop];
|
|
4597
4287
|
}
|
|
4598
|
-
|
|
4599
|
-
this._isNativeImpl = supported;
|
|
4600
|
-
}
|
|
4601
|
-
animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
|
|
4602
|
-
const useKeyframes = !scrubberAccessRequested && !this._isNativeImpl;
|
|
4603
|
-
if (useKeyframes) {
|
|
4604
|
-
return this._cssKeyframesDriver.animate(element, keyframes, duration, delay, easing, previousPlayers);
|
|
4605
|
-
}
|
|
4288
|
+
animate(element, keyframes, duration, delay, easing, previousPlayers = []) {
|
|
4606
4289
|
const fill = delay == 0 ? 'both' : 'forwards';
|
|
4607
4290
|
const playerOptions = { duration, delay, fill };
|
|
4608
4291
|
// we check for this to avoid having a null|undefined value be present
|
|
@@ -4624,12 +4307,6 @@ class WebAnimationsDriver {
|
|
|
4624
4307
|
return new WebAnimationsPlayer(element, keyframes, playerOptions, specialStyles);
|
|
4625
4308
|
}
|
|
4626
4309
|
}
|
|
4627
|
-
function supportsWebAnimations() {
|
|
4628
|
-
return typeof getElementAnimateFn() === 'function';
|
|
4629
|
-
}
|
|
4630
|
-
function getElementAnimateFn() {
|
|
4631
|
-
return (isBrowser() && Element.prototype['animate']) || {};
|
|
4632
|
-
}
|
|
4633
4310
|
|
|
4634
4311
|
/**
|
|
4635
4312
|
* @license
|
|
@@ -4667,5 +4344,5 @@ function getElementAnimateFn() {
|
|
|
4667
4344
|
* Generated bundle index. Do not edit.
|
|
4668
4345
|
*/
|
|
4669
4346
|
|
|
4670
|
-
export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer,
|
|
4347
|
+
export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationDriver as ɵNoopAnimationDriver, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, containsElement as ɵcontainsElement, invokeQuery as ɵinvokeQuery, validateStyleProperty as ɵvalidateStyleProperty };
|
|
4671
4348
|
//# sourceMappingURL=browser.mjs.map
|