@angular/animations 17.0.0-next.6 → 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 +48 -43
- package/browser/testing/index.d.ts +1 -1
- 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 +3 -3
- package/esm2022/browser/src/render/animation_renderer.mjs +11 -165
- package/esm2022/browser/src/render/renderer.mjs +157 -0
- package/esm2022/src/version.mjs +1 -1
- package/fesm2022/animations.mjs +1 -1
- package/fesm2022/browser/testing.mjs +1 -1
- package/fesm2022/browser.mjs +405 -398
- package/fesm2022/browser.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
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
|
*/
|
@@ -545,10 +545,10 @@ class NoopAnimationDriver {
|
|
545
545
|
animate(element, keyframes, duration, delay, easing, previousPlayers = [], scrubberAccessRequested) {
|
546
546
|
return new NoopAnimationPlayer(duration, delay);
|
547
547
|
}
|
548
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.
|
549
|
-
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 }); }
|
550
550
|
}
|
551
|
-
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: [{
|
552
552
|
type: Injectable
|
553
553
|
}] });
|
554
554
|
/**
|
@@ -561,6 +561,17 @@ class AnimationDriver {
|
|
561
561
|
static { this.NOOP = ( /* @__PURE__ */new NoopAnimationDriver()); }
|
562
562
|
}
|
563
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
|
+
|
564
575
|
const ONE_SECOND = 1000;
|
565
576
|
const SUBSTITUTION_EXPR_START = '{{';
|
566
577
|
const SUBSTITUTION_EXPR_END = '}}';
|
@@ -810,6 +821,59 @@ function computeStyle(element, prop) {
|
|
810
821
|
return window.getComputedStyle(element)[prop];
|
811
822
|
}
|
812
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
|
+
|
813
877
|
function createListOfWarnings(warnings) {
|
814
878
|
const LINE_START = '\n - ';
|
815
879
|
return `${LINE_START}${warnings.filter(Boolean).map(warning => warning).join(LINE_START)}`;
|
@@ -2198,99 +2262,6 @@ function flattenStyles(input, allStyles) {
|
|
2198
2262
|
return styles;
|
2199
2263
|
}
|
2200
2264
|
|
2201
|
-
class Animation {
|
2202
|
-
constructor(_driver, input) {
|
2203
|
-
this._driver = _driver;
|
2204
|
-
const errors = [];
|
2205
|
-
const warnings = [];
|
2206
|
-
const ast = buildAnimationAst(_driver, input, errors, warnings);
|
2207
|
-
if (errors.length) {
|
2208
|
-
throw validationFailed(errors);
|
2209
|
-
}
|
2210
|
-
if (warnings.length) {
|
2211
|
-
warnValidation(warnings);
|
2212
|
-
}
|
2213
|
-
this._animationAst = ast;
|
2214
|
-
}
|
2215
|
-
buildTimelines(element, startingStyles, destinationStyles, options, subInstructions) {
|
2216
|
-
const start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) :
|
2217
|
-
startingStyles;
|
2218
|
-
const dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) :
|
2219
|
-
destinationStyles;
|
2220
|
-
const errors = [];
|
2221
|
-
subInstructions = subInstructions || new ElementInstructionMap();
|
2222
|
-
const result = buildAnimationTimelines(this._driver, element, this._animationAst, ENTER_CLASSNAME, LEAVE_CLASSNAME, start, dest, options, subInstructions, errors);
|
2223
|
-
if (errors.length) {
|
2224
|
-
throw buildingFailed(errors);
|
2225
|
-
}
|
2226
|
-
return result;
|
2227
|
-
}
|
2228
|
-
}
|
2229
|
-
|
2230
|
-
class AnimationStyleNormalizer {
|
2231
|
-
}
|
2232
|
-
class NoopAnimationStyleNormalizer {
|
2233
|
-
normalizePropertyName(propertyName, errors) {
|
2234
|
-
return propertyName;
|
2235
|
-
}
|
2236
|
-
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
2237
|
-
return value;
|
2238
|
-
}
|
2239
|
-
}
|
2240
|
-
|
2241
|
-
const DIMENSIONAL_PROP_SET = new Set([
|
2242
|
-
'width',
|
2243
|
-
'height',
|
2244
|
-
'minWidth',
|
2245
|
-
'minHeight',
|
2246
|
-
'maxWidth',
|
2247
|
-
'maxHeight',
|
2248
|
-
'left',
|
2249
|
-
'top',
|
2250
|
-
'bottom',
|
2251
|
-
'right',
|
2252
|
-
'fontSize',
|
2253
|
-
'outlineWidth',
|
2254
|
-
'outlineOffset',
|
2255
|
-
'paddingTop',
|
2256
|
-
'paddingLeft',
|
2257
|
-
'paddingBottom',
|
2258
|
-
'paddingRight',
|
2259
|
-
'marginTop',
|
2260
|
-
'marginLeft',
|
2261
|
-
'marginBottom',
|
2262
|
-
'marginRight',
|
2263
|
-
'borderRadius',
|
2264
|
-
'borderWidth',
|
2265
|
-
'borderTopWidth',
|
2266
|
-
'borderLeftWidth',
|
2267
|
-
'borderRightWidth',
|
2268
|
-
'borderBottomWidth',
|
2269
|
-
'textIndent',
|
2270
|
-
'perspective'
|
2271
|
-
]);
|
2272
|
-
class WebAnimationsStyleNormalizer extends AnimationStyleNormalizer {
|
2273
|
-
normalizePropertyName(propertyName, errors) {
|
2274
|
-
return dashCaseToCamelCase(propertyName);
|
2275
|
-
}
|
2276
|
-
normalizeStyleValue(userProvidedProperty, normalizedProperty, value, errors) {
|
2277
|
-
let unit = '';
|
2278
|
-
const strVal = value.toString().trim();
|
2279
|
-
if (DIMENSIONAL_PROP_SET.has(normalizedProperty) && value !== 0 && value !== '0') {
|
2280
|
-
if (typeof value === 'number') {
|
2281
|
-
unit = 'px';
|
2282
|
-
}
|
2283
|
-
else {
|
2284
|
-
const valAndSuffixMatch = value.match(/^[+-]?[\d\.]+([a-z]*)$/);
|
2285
|
-
if (valAndSuffixMatch && valAndSuffixMatch[1].length == 0) {
|
2286
|
-
errors.push(invalidCssUnitValue(userProvidedProperty, value));
|
2287
|
-
}
|
2288
|
-
}
|
2289
|
-
}
|
2290
|
-
return strVal + unit;
|
2291
|
-
}
|
2292
|
-
}
|
2293
|
-
|
2294
2265
|
function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, totalTime, errors) {
|
2295
2266
|
return {
|
2296
2267
|
type: 0 /* AnimationTransitionInstructionType.TransitionAnimation */,
|
@@ -4210,309 +4181,52 @@ class AnimationEngine {
|
|
4210
4181
|
}
|
4211
4182
|
}
|
4212
4183
|
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4229
|
-
|
4230
|
-
|
4231
|
-
if (parentNode) {
|
4232
|
-
delegate.removeChild(parentNode, element);
|
4233
|
-
}
|
4234
|
-
};
|
4235
|
-
}
|
4236
|
-
createRenderer(hostElement, type) {
|
4237
|
-
const EMPTY_NAMESPACE_ID = '';
|
4238
|
-
// cache the delegates to find out which cached delegate can
|
4239
|
-
// be used by which cached renderer
|
4240
|
-
const delegate = this.delegate.createRenderer(hostElement, type);
|
4241
|
-
if (!hostElement || !type || !type.data || !type.data['animation']) {
|
4242
|
-
let renderer = this._rendererCache.get(delegate);
|
4243
|
-
if (!renderer) {
|
4244
|
-
// Ensure that the renderer is removed from the cache on destroy
|
4245
|
-
// since it may contain references to detached DOM nodes.
|
4246
|
-
const onRendererDestroy = () => this._rendererCache.delete(delegate);
|
4247
|
-
renderer =
|
4248
|
-
new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine, onRendererDestroy);
|
4249
|
-
// only cache this result when the base renderer is used
|
4250
|
-
this._rendererCache.set(delegate, renderer);
|
4251
|
-
}
|
4252
|
-
return renderer;
|
4184
|
+
/**
|
4185
|
+
* Returns an instance of `SpecialCasedStyles` if and when any special (non animateable) styles are
|
4186
|
+
* detected.
|
4187
|
+
*
|
4188
|
+
* In CSS there exist properties that cannot be animated within a keyframe animation
|
4189
|
+
* (whether it be via CSS keyframes or web-animations) and the animation implementation
|
4190
|
+
* will ignore them. This function is designed to detect those special cased styles and
|
4191
|
+
* return a container that will be executed at the start and end of the animation.
|
4192
|
+
*
|
4193
|
+
* @returns an instance of `SpecialCasedStyles` if any special styles are detected otherwise `null`
|
4194
|
+
*/
|
4195
|
+
function packageNonAnimatableStyles(element, styles) {
|
4196
|
+
let startStyles = null;
|
4197
|
+
let endStyles = null;
|
4198
|
+
if (Array.isArray(styles) && styles.length) {
|
4199
|
+
startStyles = filterNonAnimatableStyles(styles[0]);
|
4200
|
+
if (styles.length > 1) {
|
4201
|
+
endStyles = filterNonAnimatableStyles(styles[styles.length - 1]);
|
4253
4202
|
}
|
4254
|
-
const componentId = type.id;
|
4255
|
-
const namespaceId = type.id + '-' + this._currentId;
|
4256
|
-
this._currentId++;
|
4257
|
-
this.engine.register(namespaceId, hostElement);
|
4258
|
-
const registerTrigger = (trigger) => {
|
4259
|
-
if (Array.isArray(trigger)) {
|
4260
|
-
trigger.forEach(registerTrigger);
|
4261
|
-
}
|
4262
|
-
else {
|
4263
|
-
this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);
|
4264
|
-
}
|
4265
|
-
};
|
4266
|
-
const animationTriggers = type.data['animation'];
|
4267
|
-
animationTriggers.forEach(registerTrigger);
|
4268
|
-
return new AnimationRenderer(this, namespaceId, delegate, this.engine);
|
4269
4203
|
}
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4204
|
+
else if (styles instanceof Map) {
|
4205
|
+
startStyles = filterNonAnimatableStyles(styles);
|
4206
|
+
}
|
4207
|
+
return (startStyles || endStyles) ? new SpecialCasedStyles(element, startStyles, endStyles) :
|
4208
|
+
null;
|
4209
|
+
}
|
4210
|
+
/**
|
4211
|
+
* Designed to be executed during a keyframe-based animation to apply any special-cased styles.
|
4212
|
+
*
|
4213
|
+
* When started (when the `start()` method is run) then the provided `startStyles`
|
4214
|
+
* will be applied. When finished (when the `finish()` method is called) the
|
4215
|
+
* `endStyles` will be applied as well any any starting styles. Finally when
|
4216
|
+
* `destroy()` is called then all styles will be removed.
|
4217
|
+
*/
|
4218
|
+
class SpecialCasedStyles {
|
4219
|
+
static { this.initialStylesByElement = ( /* @__PURE__ */new WeakMap()); }
|
4220
|
+
constructor(_element, _startStyles, _endStyles) {
|
4221
|
+
this._element = _element;
|
4222
|
+
this._startStyles = _startStyles;
|
4223
|
+
this._endStyles = _endStyles;
|
4224
|
+
this._state = 0 /* SpecialCasedStylesState.Pending */;
|
4225
|
+
let initialStyles = SpecialCasedStyles.initialStylesByElement.get(_element);
|
4226
|
+
if (!initialStyles) {
|
4227
|
+
SpecialCasedStyles.initialStylesByElement.set(_element, initialStyles = new Map());
|
4274
4228
|
}
|
4275
|
-
|
4276
|
-
_scheduleCountTask() {
|
4277
|
-
queueMicrotask(() => {
|
4278
|
-
this._microtaskId++;
|
4279
|
-
});
|
4280
|
-
}
|
4281
|
-
/** @internal */
|
4282
|
-
scheduleListenerCallback(count, fn, data) {
|
4283
|
-
if (count >= 0 && count < this._microtaskId) {
|
4284
|
-
this._zone.run(() => fn(data));
|
4285
|
-
return;
|
4286
|
-
}
|
4287
|
-
if (this._animationCallbacksBuffer.length == 0) {
|
4288
|
-
queueMicrotask(() => {
|
4289
|
-
this._zone.run(() => {
|
4290
|
-
this._animationCallbacksBuffer.forEach(tuple => {
|
4291
|
-
const [fn, data] = tuple;
|
4292
|
-
fn(data);
|
4293
|
-
});
|
4294
|
-
this._animationCallbacksBuffer = [];
|
4295
|
-
});
|
4296
|
-
});
|
4297
|
-
}
|
4298
|
-
this._animationCallbacksBuffer.push([fn, data]);
|
4299
|
-
}
|
4300
|
-
end() {
|
4301
|
-
this._cdRecurDepth--;
|
4302
|
-
// this is to prevent animations from running twice when an inner
|
4303
|
-
// component does CD when a parent component instead has inserted it
|
4304
|
-
if (this._cdRecurDepth == 0) {
|
4305
|
-
this._zone.runOutsideAngular(() => {
|
4306
|
-
this._scheduleCountTask();
|
4307
|
-
this.engine.flush(this._microtaskId);
|
4308
|
-
});
|
4309
|
-
}
|
4310
|
-
if (this.delegate.end) {
|
4311
|
-
this.delegate.end();
|
4312
|
-
}
|
4313
|
-
}
|
4314
|
-
whenRenderingDone() {
|
4315
|
-
return this.engine.whenRenderingDone();
|
4316
|
-
}
|
4317
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0-next.6", ngImport: i0, type: AnimationRendererFactory, deps: [{ token: i0.RendererFactory2 }, { token: AnimationEngine }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
4318
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0-next.6", ngImport: i0, type: AnimationRendererFactory }); }
|
4319
|
-
}
|
4320
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.0-next.6", ngImport: i0, type: AnimationRendererFactory, decorators: [{
|
4321
|
-
type: Injectable
|
4322
|
-
}], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: AnimationEngine }, { type: i0.NgZone }] });
|
4323
|
-
class BaseAnimationRenderer {
|
4324
|
-
constructor(namespaceId, delegate, engine, _onDestroy) {
|
4325
|
-
this.namespaceId = namespaceId;
|
4326
|
-
this.delegate = delegate;
|
4327
|
-
this.engine = engine;
|
4328
|
-
this._onDestroy = _onDestroy;
|
4329
|
-
}
|
4330
|
-
get data() {
|
4331
|
-
return this.delegate.data;
|
4332
|
-
}
|
4333
|
-
destroyNode(node) {
|
4334
|
-
this.delegate.destroyNode?.(node);
|
4335
|
-
}
|
4336
|
-
destroy() {
|
4337
|
-
this.engine.destroy(this.namespaceId, this.delegate);
|
4338
|
-
this.engine.afterFlushAnimationsDone(() => {
|
4339
|
-
// Call the renderer destroy method after the animations has finished as otherwise
|
4340
|
-
// styles will be removed too early which will cause an unstyled animation.
|
4341
|
-
queueMicrotask(() => {
|
4342
|
-
this.delegate.destroy();
|
4343
|
-
});
|
4344
|
-
});
|
4345
|
-
this._onDestroy?.();
|
4346
|
-
}
|
4347
|
-
createElement(name, namespace) {
|
4348
|
-
return this.delegate.createElement(name, namespace);
|
4349
|
-
}
|
4350
|
-
createComment(value) {
|
4351
|
-
return this.delegate.createComment(value);
|
4352
|
-
}
|
4353
|
-
createText(value) {
|
4354
|
-
return this.delegate.createText(value);
|
4355
|
-
}
|
4356
|
-
appendChild(parent, newChild) {
|
4357
|
-
this.delegate.appendChild(parent, newChild);
|
4358
|
-
this.engine.onInsert(this.namespaceId, newChild, parent, false);
|
4359
|
-
}
|
4360
|
-
insertBefore(parent, newChild, refChild, isMove = true) {
|
4361
|
-
this.delegate.insertBefore(parent, newChild, refChild);
|
4362
|
-
// If `isMove` true than we should animate this insert.
|
4363
|
-
this.engine.onInsert(this.namespaceId, newChild, parent, isMove);
|
4364
|
-
}
|
4365
|
-
removeChild(parent, oldChild, isHostElement) {
|
4366
|
-
this.engine.onRemove(this.namespaceId, oldChild, this.delegate);
|
4367
|
-
}
|
4368
|
-
selectRootElement(selectorOrNode, preserveContent) {
|
4369
|
-
return this.delegate.selectRootElement(selectorOrNode, preserveContent);
|
4370
|
-
}
|
4371
|
-
parentNode(node) {
|
4372
|
-
return this.delegate.parentNode(node);
|
4373
|
-
}
|
4374
|
-
nextSibling(node) {
|
4375
|
-
return this.delegate.nextSibling(node);
|
4376
|
-
}
|
4377
|
-
setAttribute(el, name, value, namespace) {
|
4378
|
-
this.delegate.setAttribute(el, name, value, namespace);
|
4379
|
-
}
|
4380
|
-
removeAttribute(el, name, namespace) {
|
4381
|
-
this.delegate.removeAttribute(el, name, namespace);
|
4382
|
-
}
|
4383
|
-
addClass(el, name) {
|
4384
|
-
this.delegate.addClass(el, name);
|
4385
|
-
}
|
4386
|
-
removeClass(el, name) {
|
4387
|
-
this.delegate.removeClass(el, name);
|
4388
|
-
}
|
4389
|
-
setStyle(el, style, value, flags) {
|
4390
|
-
this.delegate.setStyle(el, style, value, flags);
|
4391
|
-
}
|
4392
|
-
removeStyle(el, style, flags) {
|
4393
|
-
this.delegate.removeStyle(el, style, flags);
|
4394
|
-
}
|
4395
|
-
setProperty(el, name, value) {
|
4396
|
-
if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {
|
4397
|
-
this.disableAnimations(el, !!value);
|
4398
|
-
}
|
4399
|
-
else {
|
4400
|
-
this.delegate.setProperty(el, name, value);
|
4401
|
-
}
|
4402
|
-
}
|
4403
|
-
setValue(node, value) {
|
4404
|
-
this.delegate.setValue(node, value);
|
4405
|
-
}
|
4406
|
-
listen(target, eventName, callback) {
|
4407
|
-
return this.delegate.listen(target, eventName, callback);
|
4408
|
-
}
|
4409
|
-
disableAnimations(element, value) {
|
4410
|
-
this.engine.disableAnimations(element, value);
|
4411
|
-
}
|
4412
|
-
}
|
4413
|
-
class AnimationRenderer extends BaseAnimationRenderer {
|
4414
|
-
constructor(factory, namespaceId, delegate, engine, onDestroy) {
|
4415
|
-
super(namespaceId, delegate, engine, onDestroy);
|
4416
|
-
this.factory = factory;
|
4417
|
-
this.namespaceId = namespaceId;
|
4418
|
-
}
|
4419
|
-
setProperty(el, name, value) {
|
4420
|
-
if (name.charAt(0) == ANIMATION_PREFIX) {
|
4421
|
-
if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
|
4422
|
-
value = value === undefined ? true : !!value;
|
4423
|
-
this.disableAnimations(el, value);
|
4424
|
-
}
|
4425
|
-
else {
|
4426
|
-
this.engine.process(this.namespaceId, el, name.slice(1), value);
|
4427
|
-
}
|
4428
|
-
}
|
4429
|
-
else {
|
4430
|
-
this.delegate.setProperty(el, name, value);
|
4431
|
-
}
|
4432
|
-
}
|
4433
|
-
listen(target, eventName, callback) {
|
4434
|
-
if (eventName.charAt(0) == ANIMATION_PREFIX) {
|
4435
|
-
const element = resolveElementFromTarget(target);
|
4436
|
-
let name = eventName.slice(1);
|
4437
|
-
let phase = '';
|
4438
|
-
// @listener.phase is for trigger animation callbacks
|
4439
|
-
// @@listener is for animation builder callbacks
|
4440
|
-
if (name.charAt(0) != ANIMATION_PREFIX) {
|
4441
|
-
[name, phase] = parseTriggerCallbackName(name);
|
4442
|
-
}
|
4443
|
-
return this.engine.listen(this.namespaceId, element, name, phase, event => {
|
4444
|
-
const countId = event['_data'] || -1;
|
4445
|
-
this.factory.scheduleListenerCallback(countId, callback, event);
|
4446
|
-
});
|
4447
|
-
}
|
4448
|
-
return this.delegate.listen(target, eventName, callback);
|
4449
|
-
}
|
4450
|
-
}
|
4451
|
-
function resolveElementFromTarget(target) {
|
4452
|
-
switch (target) {
|
4453
|
-
case 'body':
|
4454
|
-
return document.body;
|
4455
|
-
case 'document':
|
4456
|
-
return document;
|
4457
|
-
case 'window':
|
4458
|
-
return window;
|
4459
|
-
default:
|
4460
|
-
return target;
|
4461
|
-
}
|
4462
|
-
}
|
4463
|
-
function parseTriggerCallbackName(triggerName) {
|
4464
|
-
const dotIndex = triggerName.indexOf('.');
|
4465
|
-
const trigger = triggerName.substring(0, dotIndex);
|
4466
|
-
const phase = triggerName.slice(dotIndex + 1);
|
4467
|
-
return [trigger, phase];
|
4468
|
-
}
|
4469
|
-
|
4470
|
-
/**
|
4471
|
-
* Returns an instance of `SpecialCasedStyles` if and when any special (non animateable) styles are
|
4472
|
-
* detected.
|
4473
|
-
*
|
4474
|
-
* In CSS there exist properties that cannot be animated within a keyframe animation
|
4475
|
-
* (whether it be via CSS keyframes or web-animations) and the animation implementation
|
4476
|
-
* will ignore them. This function is designed to detect those special cased styles and
|
4477
|
-
* return a container that will be executed at the start and end of the animation.
|
4478
|
-
*
|
4479
|
-
* @returns an instance of `SpecialCasedStyles` if any special styles are detected otherwise `null`
|
4480
|
-
*/
|
4481
|
-
function packageNonAnimatableStyles(element, styles) {
|
4482
|
-
let startStyles = null;
|
4483
|
-
let endStyles = null;
|
4484
|
-
if (Array.isArray(styles) && styles.length) {
|
4485
|
-
startStyles = filterNonAnimatableStyles(styles[0]);
|
4486
|
-
if (styles.length > 1) {
|
4487
|
-
endStyles = filterNonAnimatableStyles(styles[styles.length - 1]);
|
4488
|
-
}
|
4489
|
-
}
|
4490
|
-
else if (styles instanceof Map) {
|
4491
|
-
startStyles = filterNonAnimatableStyles(styles);
|
4492
|
-
}
|
4493
|
-
return (startStyles || endStyles) ? new SpecialCasedStyles(element, startStyles, endStyles) :
|
4494
|
-
null;
|
4495
|
-
}
|
4496
|
-
/**
|
4497
|
-
* Designed to be executed during a keyframe-based animation to apply any special-cased styles.
|
4498
|
-
*
|
4499
|
-
* When started (when the `start()` method is run) then the provided `startStyles`
|
4500
|
-
* will be applied. When finished (when the `finish()` method is called) the
|
4501
|
-
* `endStyles` will be applied as well any any starting styles. Finally when
|
4502
|
-
* `destroy()` is called then all styles will be removed.
|
4503
|
-
*/
|
4504
|
-
class SpecialCasedStyles {
|
4505
|
-
static { this.initialStylesByElement = ( /* @__PURE__ */new WeakMap()); }
|
4506
|
-
constructor(_element, _startStyles, _endStyles) {
|
4507
|
-
this._element = _element;
|
4508
|
-
this._startStyles = _startStyles;
|
4509
|
-
this._endStyles = _endStyles;
|
4510
|
-
this._state = 0 /* SpecialCasedStylesState.Pending */;
|
4511
|
-
let initialStyles = SpecialCasedStyles.initialStylesByElement.get(_element);
|
4512
|
-
if (!initialStyles) {
|
4513
|
-
SpecialCasedStyles.initialStylesByElement.set(_element, initialStyles = new Map());
|
4514
|
-
}
|
4515
|
-
this._initialStyles = initialStyles;
|
4229
|
+
this._initialStyles = initialStyles;
|
4516
4230
|
}
|
4517
4231
|
start() {
|
4518
4232
|
if (this._state < 1 /* SpecialCasedStylesState.Started */) {
|
@@ -4787,6 +4501,299 @@ class WebAnimationsDriver {
|
|
4787
4501
|
}
|
4788
4502
|
}
|
4789
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
|
+
|
4790
4797
|
/**
|
4791
4798
|
* @module
|
4792
4799
|
* @description
|
@@ -4805,5 +4812,5 @@ class WebAnimationsDriver {
|
|
4805
4812
|
* Generated bundle index. Do not edit.
|
4806
4813
|
*/
|
4807
4814
|
|
4808
|
-
export { AnimationDriver, NoopAnimationDriver, Animation as ɵAnimation, AnimationEngine as ɵAnimationEngine, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, AnimationStyleNormalizer as ɵAnimationStyleNormalizer, NoopAnimationStyleNormalizer as ɵNoopAnimationStyleNormalizer, WebAnimationsDriver as ɵWebAnimationsDriver, WebAnimationsPlayer as ɵWebAnimationsPlayer, WebAnimationsStyleNormalizer as ɵWebAnimationsStyleNormalizer, allowPreviousPlayerStylesMerge as ɵallowPreviousPlayerStylesMerge, camelCaseToDashCase as ɵcamelCaseToDashCase, containsElement as ɵcontainsElement, getParentElement as ɵgetParentElement, invokeQuery as ɵinvokeQuery, normalizeKeyframes as ɵnormalizeKeyframes, validateStyleProperty as ɵvalidateStyleProperty, validateWebAnimatableStyleProperty as ɵvalidateWebAnimatableStyleProperty };
|
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 };
|
4809
4816
|
//# sourceMappingURL=browser.mjs.map
|