@angular/animations 17.0.0-next.5 → 17.0.0-next.7
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/browser/index.d.ts +112 -13
- package/browser/testing/index.d.ts +1 -1
- package/esm2022/browser/src/browser.mjs +2 -2
- package/esm2022/browser/src/create_engine.mjs +20 -0
- package/esm2022/browser/src/private_export.mjs +4 -2
- package/esm2022/browser/src/render/animation_driver.mjs +35 -4
- package/esm2022/browser/src/render/animation_renderer.mjs +107 -0
- package/esm2022/browser/src/render/renderer.mjs +157 -0
- package/esm2022/browser/src/render/transition_animation_engine.mjs +1 -1
- package/esm2022/src/version.mjs +1 -1
- package/fesm2022/animations.mjs +1 -1
- package/fesm2022/browser/testing.mjs +1 -1
- package/fesm2022/browser.mjs +393 -98
- package/fesm2022/browser.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
package/esm2022/src/version.mjs
CHANGED
@@ -11,5 +11,5 @@
|
|
11
11
|
* Entry point for all public APIs of the animation package.
|
12
12
|
*/
|
13
13
|
import { Version } from '@angular/core';
|
14
|
-
export const VERSION = new Version('17.0.0-next.
|
14
|
+
export const VERSION = new Version('17.0.0-next.7');
|
15
15
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2FuaW1hdGlvbnMvc3JjL3ZlcnNpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUg7Ozs7R0FJRztBQUNILE9BQU8sRUFBQyxPQUFPLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFdEMsTUFBTSxDQUFDLE1BQU0sT0FBTyxHQUFHLElBQUksT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEBsaWNlbnNlXG4gKiBDb3B5cmlnaHQgR29vZ2xlIExMQyBBbGwgUmlnaHRzIFJlc2VydmVkLlxuICpcbiAqIFVzZSBvZiB0aGlzIHNvdXJjZSBjb2RlIGlzIGdvdmVybmVkIGJ5IGFuIE1JVC1zdHlsZSBsaWNlbnNlIHRoYXQgY2FuIGJlXG4gKiBmb3VuZCBpbiB0aGUgTElDRU5TRSBmaWxlIGF0IGh0dHBzOi8vYW5ndWxhci5pby9saWNlbnNlXG4gKi9cblxuLyoqXG4gKiBAbW9kdWxlXG4gKiBAZGVzY3JpcHRpb25cbiAqIEVudHJ5IHBvaW50IGZvciBhbGwgcHVibGljIEFQSXMgb2YgdGhlIGFuaW1hdGlvbiBwYWNrYWdlLlxuICovXG5pbXBvcnQge1ZlcnNpb259IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG5leHBvcnQgY29uc3QgVkVSU0lPTiA9IG5ldyBWZXJzaW9uKCcwLjAuMC1QTEFDRUhPTERFUicpO1xuIl19
|
package/fesm2022/animations.mjs
CHANGED
package/fesm2022/browser.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @license Angular v17.0.0-next.
|
2
|
+
* @license Angular v17.0.0-next.7
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
4
4
|
* License: MIT
|
5
5
|
*/
|
@@ -494,42 +494,84 @@ function hypenatePropsKeys(original) {
|
|
494
494
|
return newMap;
|
495
495
|
}
|
496
496
|
|
497
|
+
/**
|
498
|
+
* @publicApi
|
499
|
+
*
|
500
|
+
* `AnimationDriver` implentation for Noop animations
|
501
|
+
*/
|
497
502
|
class NoopAnimationDriver {
|
503
|
+
/**
|
504
|
+
* @returns Whether `prop` is a valid CSS property
|
505
|
+
*/
|
498
506
|
validateStyleProperty(prop) {
|
499
507
|
return validateStyleProperty(prop);
|
500
508
|
}
|
509
|
+
/**
|
510
|
+
* @deprecated unused
|
511
|
+
*/
|
501
512
|
matchesElement(_element, _selector) {
|
502
513
|
// This method is deprecated and no longer in use so we return false.
|
503
514
|
return false;
|
504
515
|
}
|
516
|
+
/**
|
517
|
+
*
|
518
|
+
* @returns Whether elm1 contains elm2.
|
519
|
+
*/
|
505
520
|
containsElement(elm1, elm2) {
|
506
521
|
return containsElement(elm1, elm2);
|
507
522
|
}
|
523
|
+
/**
|
524
|
+
* @returns Rhe parent of the given element or `null` if the element is the `document`
|
525
|
+
*/
|
508
526
|
getParentElement(element) {
|
509
527
|
return getParentElement(element);
|
510
528
|
}
|
529
|
+
/**
|
530
|
+
* @returns The result of the query selector on the element. The array will contain up to 1 item
|
531
|
+
* if `multi` is `false`.
|
532
|
+
*/
|
511
533
|
query(element, selector, multi) {
|
512
534
|
return invokeQuery(element, selector, multi);
|
513
535
|
}
|
536
|
+
/**
|
537
|
+
* @returns The `defaultValue` or empty string
|
538
|
+
*/
|
514
539
|
computeStyle(element, prop, defaultValue) {
|
515
540
|
return defaultValue || '';
|
516
541
|
}
|
542
|
+
/**
|
543
|
+
* @returns An `NoopAnimationPlayer`
|
544
|
+
*/
|
517
545
|
animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
|
518
546
|
return new NoopAnimationPlayer(duration, delay);
|
519
547
|
}
|
520
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
521
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.
|
548
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.7", ngImport: i0, type: NoopAnimationDriver, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
549
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.7", ngImport: i0, type: NoopAnimationDriver }); }
|
522
550
|
}
|
523
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.
|
551
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.7", ngImport: i0, type: NoopAnimationDriver, decorators: [{
|
524
552
|
type: Injectable
|
525
553
|
}] });
|
526
554
|
/**
|
527
555
|
* @publicApi
|
528
556
|
*/
|
529
557
|
class AnimationDriver {
|
558
|
+
/**
|
559
|
+
* @deprecated Use the NoopAnimationDriver class.
|
560
|
+
*/
|
530
561
|
static { this.NOOP = ( /* @__PURE__ */new NoopAnimationDriver()); }
|
531
562
|
}
|
532
563
|
|
564
|
+
class AnimationStyleNormalizer {
|
565
|
+
}
|
566
|
+
class NoopAnimationStyleNormalizer {
|
567
|
+
normalizePropertyName(propertyName, errors) {
|
568
|
+
return propertyName;
|
569
|
+
}
|
570
|
+
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
571
|
+
return value;
|
572
|
+
}
|
573
|
+
}
|
574
|
+
|
533
575
|
const ONE_SECOND = 1000;
|
534
576
|
const SUBSTITUTION_EXPR_START = '{{';
|
535
577
|
const SUBSTITUTION_EXPR_END = '}}';
|
@@ -779,6 +821,59 @@ function computeStyle(element, prop) {
|
|
779
821
|
return window.getComputedStyle(element)[prop];
|
780
822
|
}
|
781
823
|
|
824
|
+
const DIMENSIONAL_PROP_SET = new Set([
|
825
|
+
'width',
|
826
|
+
'height',
|
827
|
+
'minWidth',
|
828
|
+
'minHeight',
|
829
|
+
'maxWidth',
|
830
|
+
'maxHeight',
|
831
|
+
'left',
|
832
|
+
'top',
|
833
|
+
'bottom',
|
834
|
+
'right',
|
835
|
+
'fontSize',
|
836
|
+
'outlineWidth',
|
837
|
+
'outlineOffset',
|
838
|
+
'paddingTop',
|
839
|
+
'paddingLeft',
|
840
|
+
'paddingBottom',
|
841
|
+
'paddingRight',
|
842
|
+
'marginTop',
|
843
|
+
'marginLeft',
|
844
|
+
'marginBottom',
|
845
|
+
'marginRight',
|
846
|
+
'borderRadius',
|
847
|
+
'borderWidth',
|
848
|
+
'borderTopWidth',
|
849
|
+
'borderLeftWidth',
|
850
|
+
'borderRightWidth',
|
851
|
+
'borderBottomWidth',
|
852
|
+
'textIndent',
|
853
|
+
'perspective'
|
854
|
+
]);
|
855
|
+
class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
|
856
|
+
normalizePropertyName(propertyName, errors) {
|
857
|
+
return dashCaseToCamelCase(propertyName);
|
858
|
+
}
|
859
|
+
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
860
|
+
let unit = '';
|
861
|
+
const strVal = value.toString().trim();
|
862
|
+
if (DIMENSIONAL_PROP_SET.has(normalizedProperty) && value !== 0 && value !== '0') {
|
863
|
+
if (typeof value === 'number') {
|
864
|
+
unit = 'px';
|
865
|
+
}
|
866
|
+
else {
|
867
|
+
const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
|
868
|
+
if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
|
869
|
+
errors.push(invalidCssUnitValue(userProvidedProperty, value));
|
870
|
+
}
|
871
|
+
}
|
872
|
+
}
|
873
|
+
return strVal + unit;
|
874
|
+
}
|
875
|
+
}
|
876
|
+
|
782
877
|
function createListOfWarnings(warnings) {
|
783
878
|
const LINE_START = '\n - ';
|
784
879
|
return `${LINE_START}${warnings.filter(Boolean).map(warning => warning).join(LINE_START)}`;
|
@@ -2167,99 +2262,6 @@ function flattenStyles(input, allStyles) {
|
|
2167
2262
|
return styles;
|
2168
2263
|
}
|
2169
2264
|
|
2170
|
-
class Animation {
|
2171
|
-
constructor(_driver, input) {
|
2172
|
-
this._driver = _driver;
|
2173
|
-
const errors = [];
|
2174
|
-
const warnings = [];
|
2175
|
-
const ast = buildAnimationAst(_driver, input, errors, warnings);
|
2176
|
-
if (errors.length) {
|
2177
|
-
throw validationFailed(errors);
|
2178
|
-
}
|
2179
|
-
if (warnings.length) {
|
2180
|
-
warnValidation(warnings);
|
2181
|
-
}
|
2182
|
-
this._animationAst = ast;
|
2183
|
-
}
|
2184
|
-
buildTimelines(element, startingStyles, destinationStyles, options, subInstructions) {
|
2185
|
-
const start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) :
|
2186
|
-
startingStyles;
|
2187
|
-
const dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) :
|
2188
|
-
destinationStyles;
|
2189
|
-
const errors = [];
|
2190
|
-
subInstructions = subInstructions || new ElementInstructionMap();
|
2191
|
-
const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
|
2192
|
-
if (errors.length) {
|
2193
|
-
throw buildingFailed(errors);
|
2194
|
-
}
|
2195
|
-
return result;
|
2196
|
-
}
|
2197
|
-
}
|
2198
|
-
|
2199
|
-
class AnimationStyleNormalizer {
|
2200
|
-
}
|
2201
|
-
class NoopAnimationStyleNormalizer {
|
2202
|
-
normalizePropertyName(propertyName, errors) {
|
2203
|
-
return propertyName;
|
2204
|
-
}
|
2205
|
-
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
2206
|
-
return value;
|
2207
|
-
}
|
2208
|
-
}
|
2209
|
-
|
2210
|
-
const DIMENSIONAL_PROP_SET = new Set([
|
2211
|
-
'width',
|
2212
|
-
'height',
|
2213
|
-
'minWidth',
|
2214
|
-
'minHeight',
|
2215
|
-
'maxWidth',
|
2216
|
-
'maxHeight',
|
2217
|
-
'left',
|
2218
|
-
'top',
|
2219
|
-
'bottom',
|
2220
|
-
'right',
|
2221
|
-
'fontSize',
|
2222
|
-
'outlineWidth',
|
2223
|
-
'outlineOffset',
|
2224
|
-
'paddingTop',
|
2225
|
-
'paddingLeft',
|
2226
|
-
'paddingBottom',
|
2227
|
-
'paddingRight',
|
2228
|
-
'marginTop',
|
2229
|
-
'marginLeft',
|
2230
|
-
'marginBottom',
|
2231
|
-
'marginRight',
|
2232
|
-
'borderRadius',
|
2233
|
-
'borderWidth',
|
2234
|
-
'borderTopWidth',
|
2235
|
-
'borderLeftWidth',
|
2236
|
-
'borderRightWidth',
|
2237
|
-
'borderBottomWidth',
|
2238
|
-
'textIndent',
|
2239
|
-
'perspective'
|
2240
|
-
]);
|
2241
|
-
class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
|
2242
|
-
normalizePropertyName(propertyName, errors) {
|
2243
|
-
return dashCaseToCamelCase(propertyName);
|
2244
|
-
}
|
2245
|
-
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
2246
|
-
let unit = '';
|
2247
|
-
const strVal = value.toString().trim();
|
2248
|
-
if (DIMENSIONAL_PROP_SET.has(normalizedProperty) && value !== 0 && value !== '0') {
|
2249
|
-
if (typeof value === 'number') {
|
2250
|
-
unit = 'px';
|
2251
|
-
}
|
2252
|
-
else {
|
2253
|
-
const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
|
2254
|
-
if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
|
2255
|
-
errors.push(invalidCssUnitValue(userProvidedProperty, value));
|
2256
|
-
}
|
2257
|
-
}
|
2258
|
-
}
|
2259
|
-
return strVal + unit;
|
2260
|
-
}
|
2261
|
-
}
|
2262
|
-
|
2263
2265
|
function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, totalTime, errors) {
|
2264
2266
|
return {
|
2265
2267
|
type: 0 /* AnimationTransitionInstructionType.TransitionAnimation */,
|
@@ -4499,6 +4501,299 @@ class WebAnimationsDriver {
|
|
4499
4501
|
}
|
4500
4502
|
}
|
4501
4503
|
|
4504
|
+
function createEngine(type, doc) {
|
4505
|
+
// TODO: find a way to make this tree shakable.
|
4506
|
+
if (type === 'noop') {
|
4507
|
+
return new AnimationEngine(doc, new NoopAnimationDriver(), new NoopAnimationStyleNormalizer());
|
4508
|
+
}
|
4509
|
+
return new AnimationEngine(doc, new WebAnimationsDriver(), new WebAnimationsStyleNormalizer());
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
class Animation {
|
4513
|
+
constructor(_driver, input) {
|
4514
|
+
this._driver = _driver;
|
4515
|
+
const errors = [];
|
4516
|
+
const warnings = [];
|
4517
|
+
const ast = buildAnimationAst(_driver, input, errors, warnings);
|
4518
|
+
if (errors.length) {
|
4519
|
+
throw validationFailed(errors);
|
4520
|
+
}
|
4521
|
+
if (warnings.length) {
|
4522
|
+
warnValidation(warnings);
|
4523
|
+
}
|
4524
|
+
this._animationAst = ast;
|
4525
|
+
}
|
4526
|
+
buildTimelines(element, startingStyles, destinationStyles, options, subInstructions) {
|
4527
|
+
const start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) :
|
4528
|
+
startingStyles;
|
4529
|
+
const dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) :
|
4530
|
+
destinationStyles;
|
4531
|
+
const errors = [];
|
4532
|
+
subInstructions = subInstructions || new ElementInstructionMap();
|
4533
|
+
const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
|
4534
|
+
if (errors.length) {
|
4535
|
+
throw buildingFailed(errors);
|
4536
|
+
}
|
4537
|
+
return result;
|
4538
|
+
}
|
4539
|
+
}
|
4540
|
+
|
4541
|
+
const ANIMATION_PREFIX = '@';
|
4542
|
+
const DISABLE_ANIMATIONS_FLAG = '@.disabled';
|
4543
|
+
class BaseAnimationRenderer {
|
4544
|
+
constructor(namespaceId, delegate, engine, _onDestroy) {
|
4545
|
+
this.namespaceId = namespaceId;
|
4546
|
+
this.delegate = delegate;
|
4547
|
+
this.engine = engine;
|
4548
|
+
this._onDestroy = _onDestroy;
|
4549
|
+
this.isAnimationRenderer = true;
|
4550
|
+
}
|
4551
|
+
get data() {
|
4552
|
+
return this.delegate.data;
|
4553
|
+
}
|
4554
|
+
destroyNode(node) {
|
4555
|
+
this.delegate.destroyNode?.(node);
|
4556
|
+
}
|
4557
|
+
destroy() {
|
4558
|
+
this.engine.destroy(this.namespaceId, this.delegate);
|
4559
|
+
this.engine.afterFlushAnimationsDone(() => {
|
4560
|
+
// Call the renderer destroy method after the animations has finished as otherwise
|
4561
|
+
// styles will be removed too early which will cause an unstyled animation.
|
4562
|
+
queueMicrotask(() => {
|
4563
|
+
this.delegate.destroy();
|
4564
|
+
});
|
4565
|
+
});
|
4566
|
+
this._onDestroy?.();
|
4567
|
+
}
|
4568
|
+
createElement(name, namespace) {
|
4569
|
+
return this.delegate.createElement(name, namespace);
|
4570
|
+
}
|
4571
|
+
createComment(value) {
|
4572
|
+
return this.delegate.createComment(value);
|
4573
|
+
}
|
4574
|
+
createText(value) {
|
4575
|
+
return this.delegate.createText(value);
|
4576
|
+
}
|
4577
|
+
appendChild(parent, newChild) {
|
4578
|
+
this.delegate.appendChild(parent, newChild);
|
4579
|
+
this.engine.onInsert(this.namespaceId, newChild, parent, false);
|
4580
|
+
}
|
4581
|
+
insertBefore(parent, newChild, refChild, isMove = true) {
|
4582
|
+
this.delegate.insertBefore(parent, newChild, refChild);
|
4583
|
+
// If `isMove` true than we should animate this insert.
|
4584
|
+
this.engine.onInsert(this.namespaceId, newChild, parent, isMove);
|
4585
|
+
}
|
4586
|
+
removeChild(parent, oldChild, isHostElement) {
|
4587
|
+
this.engine.onRemove(this.namespaceId, oldChild, this.delegate);
|
4588
|
+
}
|
4589
|
+
selectRootElement(selectorOrNode, preserveContent) {
|
4590
|
+
return this.delegate.selectRootElement(selectorOrNode, preserveContent);
|
4591
|
+
}
|
4592
|
+
parentNode(node) {
|
4593
|
+
return this.delegate.parentNode(node);
|
4594
|
+
}
|
4595
|
+
nextSibling(node) {
|
4596
|
+
return this.delegate.nextSibling(node);
|
4597
|
+
}
|
4598
|
+
setAttribute(el, name, value, namespace) {
|
4599
|
+
this.delegate.setAttribute(el, name, value, namespace);
|
4600
|
+
}
|
4601
|
+
removeAttribute(el, name, namespace) {
|
4602
|
+
this.delegate.removeAttribute(el, name, namespace);
|
4603
|
+
}
|
4604
|
+
addClass(el, name) {
|
4605
|
+
this.delegate.addClass(el, name);
|
4606
|
+
}
|
4607
|
+
removeClass(el, name) {
|
4608
|
+
this.delegate.removeClass(el, name);
|
4609
|
+
}
|
4610
|
+
setStyle(el, style, value, flags) {
|
4611
|
+
this.delegate.setStyle(el, style, value, flags);
|
4612
|
+
}
|
4613
|
+
removeStyle(el, style, flags) {
|
4614
|
+
this.delegate.removeStyle(el, style, flags);
|
4615
|
+
}
|
4616
|
+
setProperty(el, name, value) {
|
4617
|
+
if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {
|
4618
|
+
this.disableAnimations(el, !!value);
|
4619
|
+
}
|
4620
|
+
else {
|
4621
|
+
this.delegate.setProperty(el, name, value);
|
4622
|
+
}
|
4623
|
+
}
|
4624
|
+
setValue(node, value) {
|
4625
|
+
this.delegate.setValue(node, value);
|
4626
|
+
}
|
4627
|
+
listen(target, eventName, callback) {
|
4628
|
+
return this.delegate.listen(target, eventName, callback);
|
4629
|
+
}
|
4630
|
+
disableAnimations(element, value) {
|
4631
|
+
this.engine.disableAnimations(element, value);
|
4632
|
+
}
|
4633
|
+
}
|
4634
|
+
class AnimationRenderer extends BaseAnimationRenderer {
|
4635
|
+
constructor(factory, namespaceId, delegate, engine, onDestroy) {
|
4636
|
+
super(namespaceId, delegate, engine, onDestroy);
|
4637
|
+
this.factory = factory;
|
4638
|
+
this.namespaceId = namespaceId;
|
4639
|
+
}
|
4640
|
+
setProperty(el, name, value) {
|
4641
|
+
if (name.charAt(0) == ANIMATION_PREFIX) {
|
4642
|
+
if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
|
4643
|
+
value = value === undefined ? true : !!value;
|
4644
|
+
this.disableAnimations(el, value);
|
4645
|
+
}
|
4646
|
+
else {
|
4647
|
+
this.engine.process(this.namespaceId, el, name.slice(1), value);
|
4648
|
+
}
|
4649
|
+
}
|
4650
|
+
else {
|
4651
|
+
this.delegate.setProperty(el, name, value);
|
4652
|
+
}
|
4653
|
+
}
|
4654
|
+
listen(target, eventName, callback) {
|
4655
|
+
if (eventName.charAt(0) == ANIMATION_PREFIX) {
|
4656
|
+
const element = resolveElementFromTarget(target);
|
4657
|
+
let name = eventName.slice(1);
|
4658
|
+
let phase = '';
|
4659
|
+
// @listener.phase is for trigger animation callbacks
|
4660
|
+
// @@listener is for animation builder callbacks
|
4661
|
+
if (name.charAt(0) != ANIMATION_PREFIX) {
|
4662
|
+
[name, phase] = parseTriggerCallbackName(name);
|
4663
|
+
}
|
4664
|
+
return this.engine.listen(this.namespaceId, element, name, phase, event => {
|
4665
|
+
const countId = event['_data'] || -1;
|
4666
|
+
this.factory.scheduleListenerCallback(countId, callback, event);
|
4667
|
+
});
|
4668
|
+
}
|
4669
|
+
return this.delegate.listen(target, eventName, callback);
|
4670
|
+
}
|
4671
|
+
}
|
4672
|
+
function resolveElementFromTarget(target) {
|
4673
|
+
switch (target) {
|
4674
|
+
case 'body':
|
4675
|
+
return document.body;
|
4676
|
+
case 'document':
|
4677
|
+
return document;
|
4678
|
+
case 'window':
|
4679
|
+
return window;
|
4680
|
+
default:
|
4681
|
+
return target;
|
4682
|
+
}
|
4683
|
+
}
|
4684
|
+
function parseTriggerCallbackName(triggerName) {
|
4685
|
+
const dotIndex = triggerName.indexOf('.');
|
4686
|
+
const trigger = triggerName.substring(0, dotIndex);
|
4687
|
+
const phase = triggerName.slice(dotIndex + 1);
|
4688
|
+
return [trigger, phase];
|
4689
|
+
}
|
4690
|
+
|
4691
|
+
class AnimationRendererFactory {
|
4692
|
+
constructor(delegate, engine, _zone) {
|
4693
|
+
this.delegate = delegate;
|
4694
|
+
this.engine = engine;
|
4695
|
+
this._zone = _zone;
|
4696
|
+
this._currentId = 0;
|
4697
|
+
this._microtaskId = 1;
|
4698
|
+
this._animationCallbacksBuffer = [];
|
4699
|
+
this._rendererCache = new Map();
|
4700
|
+
this._cdRecurDepth = 0;
|
4701
|
+
engine.onRemovalComplete = (element, delegate) => {
|
4702
|
+
// Note: if a component element has a leave animation, and a host leave animation,
|
4703
|
+
// the view engine will call `removeChild` for the parent
|
4704
|
+
// component renderer as well as for the child component renderer.
|
4705
|
+
// Therefore, we need to check if we already removed the element.
|
4706
|
+
const parentNode = delegate?.parentNode(element);
|
4707
|
+
if (parentNode) {
|
4708
|
+
delegate.removeChild(parentNode, element);
|
4709
|
+
}
|
4710
|
+
};
|
4711
|
+
}
|
4712
|
+
createRenderer(hostElement, type) {
|
4713
|
+
const EMPTY_NAMESPACE_ID = '';
|
4714
|
+
// cache the delegates to find out which cached delegate can
|
4715
|
+
// be used by which cached renderer
|
4716
|
+
const delegate = this.delegate.createRenderer(hostElement, type);
|
4717
|
+
if (!hostElement || !type?.data?.['animation']) {
|
4718
|
+
const cache = this._rendererCache;
|
4719
|
+
let renderer = cache.get(delegate);
|
4720
|
+
if (!renderer) {
|
4721
|
+
// Ensure that the renderer is removed from the cache on destroy
|
4722
|
+
// since it may contain references to detached DOM nodes.
|
4723
|
+
const onRendererDestroy = () => cache.delete(delegate);
|
4724
|
+
renderer =
|
4725
|
+
new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine, onRendererDestroy);
|
4726
|
+
// only cache this result when the base renderer is used
|
4727
|
+
cache.set(delegate, renderer);
|
4728
|
+
}
|
4729
|
+
return renderer;
|
4730
|
+
}
|
4731
|
+
const componentId = type.id;
|
4732
|
+
const namespaceId = type.id + '-' + this._currentId;
|
4733
|
+
this._currentId++;
|
4734
|
+
this.engine.register(namespaceId, hostElement);
|
4735
|
+
const registerTrigger = (trigger) => {
|
4736
|
+
if (Array.isArray(trigger)) {
|
4737
|
+
trigger.forEach(registerTrigger);
|
4738
|
+
}
|
4739
|
+
else {
|
4740
|
+
this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);
|
4741
|
+
}
|
4742
|
+
};
|
4743
|
+
const animationTriggers = type.data['animation'];
|
4744
|
+
animationTriggers.forEach(registerTrigger);
|
4745
|
+
return new AnimationRenderer(this, namespaceId, delegate, this.engine);
|
4746
|
+
}
|
4747
|
+
begin() {
|
4748
|
+
this._cdRecurDepth++;
|
4749
|
+
if (this.delegate.begin) {
|
4750
|
+
this.delegate.begin();
|
4751
|
+
}
|
4752
|
+
}
|
4753
|
+
_scheduleCountTask() {
|
4754
|
+
queueMicrotask(() => {
|
4755
|
+
this._microtaskId++;
|
4756
|
+
});
|
4757
|
+
}
|
4758
|
+
/** @internal */
|
4759
|
+
scheduleListenerCallback(count, fn, data) {
|
4760
|
+
if (count >= 0 && count < this._microtaskId) {
|
4761
|
+
this._zone.run(() => fn(data));
|
4762
|
+
return;
|
4763
|
+
}
|
4764
|
+
const animationCallbacksBuffer = this._animationCallbacksBuffer;
|
4765
|
+
if (animationCallbacksBuffer.length == 0) {
|
4766
|
+
queueMicrotask(() => {
|
4767
|
+
this._zone.run(() => {
|
4768
|
+
animationCallbacksBuffer.forEach(tuple => {
|
4769
|
+
const [fn, data] = tuple;
|
4770
|
+
fn(data);
|
4771
|
+
});
|
4772
|
+
this._animationCallbacksBuffer = [];
|
4773
|
+
});
|
4774
|
+
});
|
4775
|
+
}
|
4776
|
+
animationCallbacksBuffer.push([fn, data]);
|
4777
|
+
}
|
4778
|
+
end() {
|
4779
|
+
this._cdRecurDepth--;
|
4780
|
+
// this is to prevent animations from running twice when an inner
|
4781
|
+
// component does CD when a parent component instead has inserted it
|
4782
|
+
if (this._cdRecurDepth == 0) {
|
4783
|
+
this._zone.runOutsideAngular(() => {
|
4784
|
+
this._scheduleCountTask();
|
4785
|
+
this.engine.flush(this._microtaskId);
|
4786
|
+
});
|
4787
|
+
}
|
4788
|
+
if (this.delegate.end) {
|
4789
|
+
this.delegate.end();
|
4790
|
+
}
|
4791
|
+
}
|
4792
|
+
whenRenderingDone() {
|
4793
|
+
return this.engine.whenRenderingDone();
|
4794
|
+
}
|
4795
|
+
}
|
4796
|
+
|
4502
4797
|
/**
|
4503
4798
|
* @module
|
4504
4799
|
* @description
|
@@ -4517,5 +4812,5 @@ class WebAnimationsDriver {
|
|
4517
4812
|
* Generated bundle index. Do not edit.
|
4518
4813
|
*/
|
4519
4814
|
|
4520
|
-
export { AnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationStyleNormalizer as ɵAnimationStyleNormalizer,
|
4815
|
+
export { AnimationDriver, NoopAnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, BaseAnimationRenderer as ɵBaseAnimationRenderer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, camelCaseToDashCase as ɵcamelCaseToDashCase, containsElement as ɵcontainsElement, createEngine as ɵcreateEngine, getParentElement as ɵgetParentElement, invokeQuery as ɵinvokeQuery, normalizeKeyframes as ɵnormalizeKeyframes, validateStyleProperty as ɵvalidateStyleProperty, validateWebAnimatableStyleProperty as ɵvalidateWebAnimatableStyleProperty };
|
4521
4816
|
//# sourceMappingURL=browser.mjs.map
|