1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import * as i0 from '@angular/core';
|
8 | import { ViewEncapsulation, Injectable, Inject, InjectionToken, RendererFactory2, NgZone, NgModule } from '@angular/core';
|
9 | import { ɵDomRendererFactory2, BrowserModule } from '@angular/platform-browser';
|
10 | import { AnimationBuilder, sequence, AnimationFactory } from '@angular/animations';
|
11 | import * as i1 from '@angular/animations/browser';
|
12 | import { ɵAnimationEngine, ɵsupportsWebAnimations, ɵWebAnimationsDriver, ɵCssKeyframesDriver, ɵWebAnimationsStyleNormalizer, ɵAnimationStyleNormalizer, AnimationDriver, ɵNoopAnimationDriver } from '@angular/animations/browser';
|
13 | import { DOCUMENT } from '@angular/common';
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | class BrowserAnimationBuilder extends AnimationBuilder {
|
23 | constructor(rootRenderer, doc) {
|
24 | super();
|
25 | this._nextAnimationId = 0;
|
26 | const typeData = { id: '0', encapsulation: ViewEncapsulation.None, styles: [], data: { animation: [] } };
|
27 | this._renderer = rootRenderer.createRenderer(doc.body, typeData);
|
28 | }
|
29 | build(animation) {
|
30 | const id = this._nextAnimationId.toString();
|
31 | this._nextAnimationId++;
|
32 | const entry = Array.isArray(animation) ? sequence(animation) : animation;
|
33 | issueAnimationCommand(this._renderer, null, id, 'register', [entry]);
|
34 | return new BrowserAnimationFactory(id, this._renderer);
|
35 | }
|
36 | }
|
37 | BrowserAnimationBuilder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
38 | BrowserAnimationBuilder.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationBuilder });
|
39 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationBuilder, decorators: [{
|
40 | type: Injectable
|
41 | }], ctorParameters: function () {
|
42 | return [{ type: i0.RendererFactory2 }, { type: undefined, decorators: [{
|
43 | type: Inject,
|
44 | args: [DOCUMENT]
|
45 | }] }];
|
46 | } });
|
47 | class BrowserAnimationFactory extends AnimationFactory {
|
48 | constructor(_id, _renderer) {
|
49 | super();
|
50 | this._id = _id;
|
51 | this._renderer = _renderer;
|
52 | }
|
53 | create(element, options) {
|
54 | return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer);
|
55 | }
|
56 | }
|
57 | class RendererAnimationPlayer {
|
58 | constructor(id, element, options, _renderer) {
|
59 | this.id = id;
|
60 | this.element = element;
|
61 | this._renderer = _renderer;
|
62 | this.parentPlayer = null;
|
63 | this._started = false;
|
64 | this.totalTime = 0;
|
65 | this._command('create', options);
|
66 | }
|
67 | _listen(eventName, callback) {
|
68 | return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback);
|
69 | }
|
70 | _command(command, ...args) {
|
71 | return issueAnimationCommand(this._renderer, this.element, this.id, command, args);
|
72 | }
|
73 | onDone(fn) {
|
74 | this._listen('done', fn);
|
75 | }
|
76 | onStart(fn) {
|
77 | this._listen('start', fn);
|
78 | }
|
79 | onDestroy(fn) {
|
80 | this._listen('destroy', fn);
|
81 | }
|
82 | init() {
|
83 | this._command('init');
|
84 | }
|
85 | hasStarted() {
|
86 | return this._started;
|
87 | }
|
88 | play() {
|
89 | this._command('play');
|
90 | this._started = true;
|
91 | }
|
92 | pause() {
|
93 | this._command('pause');
|
94 | }
|
95 | restart() {
|
96 | this._command('restart');
|
97 | }
|
98 | finish() {
|
99 | this._command('finish');
|
100 | }
|
101 | destroy() {
|
102 | this._command('destroy');
|
103 | }
|
104 | reset() {
|
105 | this._command('reset');
|
106 | this._started = false;
|
107 | }
|
108 | setPosition(p) {
|
109 | this._command('setPosition', p);
|
110 | }
|
111 | getPosition() {
|
112 | var _a, _b;
|
113 | return (_b = (_a = this._renderer.engine.players[+this.id]) === null || _a === void 0 ? void 0 : _a.getPosition()) !== null && _b !== void 0 ? _b : 0;
|
114 | }
|
115 | }
|
116 | function issueAnimationCommand(renderer, element, id, command, args) {
|
117 | return renderer.setProperty(element, `@@${id}:${command}`, args);
|
118 | }
|
119 |
|
120 | const ANIMATION_PREFIX = '@';
|
121 | const DISABLE_ANIMATIONS_FLAG = '@.disabled';
|
122 | class AnimationRendererFactory {
|
123 | constructor(delegate, engine, _zone) {
|
124 | this.delegate = delegate;
|
125 | this.engine = engine;
|
126 | this._zone = _zone;
|
127 | this._currentId = 0;
|
128 | this._microtaskId = 1;
|
129 | this._animationCallbacksBuffer = [];
|
130 | this._rendererCache = new Map();
|
131 | this._cdRecurDepth = 0;
|
132 | this.promise = Promise.resolve(0);
|
133 | engine.onRemovalComplete = (element, delegate) => {
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | const parentNode = delegate === null || delegate === void 0 ? void 0 : delegate.parentNode(element);
|
139 | if (parentNode) {
|
140 | delegate.removeChild(parentNode, element);
|
141 | }
|
142 | };
|
143 | }
|
144 | createRenderer(hostElement, type) {
|
145 | const EMPTY_NAMESPACE_ID = '';
|
146 |
|
147 |
|
148 | const delegate = this.delegate.createRenderer(hostElement, type);
|
149 | if (!hostElement || !type || !type.data || !type.data['animation']) {
|
150 | let renderer = this._rendererCache.get(delegate);
|
151 | if (!renderer) {
|
152 | renderer = new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine);
|
153 |
|
154 | this._rendererCache.set(delegate, renderer);
|
155 | }
|
156 | return renderer;
|
157 | }
|
158 | const componentId = type.id;
|
159 | const namespaceId = type.id + '-' + this._currentId;
|
160 | this._currentId++;
|
161 | this.engine.register(namespaceId, hostElement);
|
162 | const registerTrigger = (trigger) => {
|
163 | if (Array.isArray(trigger)) {
|
164 | trigger.forEach(registerTrigger);
|
165 | }
|
166 | else {
|
167 | this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger);
|
168 | }
|
169 | };
|
170 | const animationTriggers = type.data['animation'];
|
171 | animationTriggers.forEach(registerTrigger);
|
172 | return new AnimationRenderer(this, namespaceId, delegate, this.engine);
|
173 | }
|
174 | begin() {
|
175 | this._cdRecurDepth++;
|
176 | if (this.delegate.begin) {
|
177 | this.delegate.begin();
|
178 | }
|
179 | }
|
180 | _scheduleCountTask() {
|
181 |
|
182 | this.promise.then(() => {
|
183 | this._microtaskId++;
|
184 | });
|
185 | }
|
186 |
|
187 | scheduleListenerCallback(count, fn, data) {
|
188 | if (count >= 0 && count < this._microtaskId) {
|
189 | this._zone.run(() => fn(data));
|
190 | return;
|
191 | }
|
192 | if (this._animationCallbacksBuffer.length == 0) {
|
193 | Promise.resolve(null).then(() => {
|
194 | this._zone.run(() => {
|
195 | this._animationCallbacksBuffer.forEach(tuple => {
|
196 | const [fn, data] = tuple;
|
197 | fn(data);
|
198 | });
|
199 | this._animationCallbacksBuffer = [];
|
200 | });
|
201 | });
|
202 | }
|
203 | this._animationCallbacksBuffer.push([fn, data]);
|
204 | }
|
205 | end() {
|
206 | this._cdRecurDepth--;
|
207 |
|
208 |
|
209 | if (this._cdRecurDepth == 0) {
|
210 | this._zone.runOutsideAngular(() => {
|
211 | this._scheduleCountTask();
|
212 | this.engine.flush(this._microtaskId);
|
213 | });
|
214 | }
|
215 | if (this.delegate.end) {
|
216 | this.delegate.end();
|
217 | }
|
218 | }
|
219 | whenRenderingDone() {
|
220 | return this.engine.whenRenderingDone();
|
221 | }
|
222 | }
|
223 | AnimationRendererFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AnimationRendererFactory, deps: [{ token: i0.RendererFactory2 }, { token: i1.ɵAnimationEngine }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
224 | AnimationRendererFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AnimationRendererFactory });
|
225 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AnimationRendererFactory, decorators: [{
|
226 | type: Injectable
|
227 | }], ctorParameters: function () { return [{ type: i0.RendererFactory2 }, { type: i1.ɵAnimationEngine }, { type: i0.NgZone }]; } });
|
228 | class BaseAnimationRenderer {
|
229 | constructor(namespaceId, delegate, engine) {
|
230 | this.namespaceId = namespaceId;
|
231 | this.delegate = delegate;
|
232 | this.engine = engine;
|
233 | this.destroyNode = this.delegate.destroyNode ? (n) => delegate.destroyNode(n) : null;
|
234 | }
|
235 | get data() {
|
236 | return this.delegate.data;
|
237 | }
|
238 | destroy() {
|
239 | this.engine.destroy(this.namespaceId, this.delegate);
|
240 | this.delegate.destroy();
|
241 | }
|
242 | createElement(name, namespace) {
|
243 | return this.delegate.createElement(name, namespace);
|
244 | }
|
245 | createComment(value) {
|
246 | return this.delegate.createComment(value);
|
247 | }
|
248 | createText(value) {
|
249 | return this.delegate.createText(value);
|
250 | }
|
251 | appendChild(parent, newChild) {
|
252 | this.delegate.appendChild(parent, newChild);
|
253 | this.engine.onInsert(this.namespaceId, newChild, parent, false);
|
254 | }
|
255 | insertBefore(parent, newChild, refChild, isMove = true) {
|
256 | this.delegate.insertBefore(parent, newChild, refChild);
|
257 |
|
258 | this.engine.onInsert(this.namespaceId, newChild, parent, isMove);
|
259 | }
|
260 | removeChild(parent, oldChild, isHostElement) {
|
261 | this.engine.onRemove(this.namespaceId, oldChild, this.delegate, isHostElement);
|
262 | }
|
263 | selectRootElement(selectorOrNode, preserveContent) {
|
264 | return this.delegate.selectRootElement(selectorOrNode, preserveContent);
|
265 | }
|
266 | parentNode(node) {
|
267 | return this.delegate.parentNode(node);
|
268 | }
|
269 | nextSibling(node) {
|
270 | return this.delegate.nextSibling(node);
|
271 | }
|
272 | setAttribute(el, name, value, namespace) {
|
273 | this.delegate.setAttribute(el, name, value, namespace);
|
274 | }
|
275 | removeAttribute(el, name, namespace) {
|
276 | this.delegate.removeAttribute(el, name, namespace);
|
277 | }
|
278 | addClass(el, name) {
|
279 | this.delegate.addClass(el, name);
|
280 | }
|
281 | removeClass(el, name) {
|
282 | this.delegate.removeClass(el, name);
|
283 | }
|
284 | setStyle(el, style, value, flags) {
|
285 | this.delegate.setStyle(el, style, value, flags);
|
286 | }
|
287 | removeStyle(el, style, flags) {
|
288 | this.delegate.removeStyle(el, style, flags);
|
289 | }
|
290 | setProperty(el, name, value) {
|
291 | if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) {
|
292 | this.disableAnimations(el, !!value);
|
293 | }
|
294 | else {
|
295 | this.delegate.setProperty(el, name, value);
|
296 | }
|
297 | }
|
298 | setValue(node, value) {
|
299 | this.delegate.setValue(node, value);
|
300 | }
|
301 | listen(target, eventName, callback) {
|
302 | return this.delegate.listen(target, eventName, callback);
|
303 | }
|
304 | disableAnimations(element, value) {
|
305 | this.engine.disableAnimations(element, value);
|
306 | }
|
307 | }
|
308 | class AnimationRenderer extends BaseAnimationRenderer {
|
309 | constructor(factory, namespaceId, delegate, engine) {
|
310 | super(namespaceId, delegate, engine);
|
311 | this.factory = factory;
|
312 | this.namespaceId = namespaceId;
|
313 | }
|
314 | setProperty(el, name, value) {
|
315 | if (name.charAt(0) == ANIMATION_PREFIX) {
|
316 | if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
|
317 | value = value === undefined ? true : !!value;
|
318 | this.disableAnimations(el, value);
|
319 | }
|
320 | else {
|
321 | this.engine.process(this.namespaceId, el, name.substr(1), value);
|
322 | }
|
323 | }
|
324 | else {
|
325 | this.delegate.setProperty(el, name, value);
|
326 | }
|
327 | }
|
328 | listen(target, eventName, callback) {
|
329 | if (eventName.charAt(0) == ANIMATION_PREFIX) {
|
330 | const element = resolveElementFromTarget(target);
|
331 | let name = eventName.substr(1);
|
332 | let phase = '';
|
333 |
|
334 |
|
335 | if (name.charAt(0) != ANIMATION_PREFIX) {
|
336 | [name, phase] = parseTriggerCallbackName(name);
|
337 | }
|
338 | return this.engine.listen(this.namespaceId, element, name, phase, event => {
|
339 | const countId = event['_data'] || -1;
|
340 | this.factory.scheduleListenerCallback(countId, callback, event);
|
341 | });
|
342 | }
|
343 | return this.delegate.listen(target, eventName, callback);
|
344 | }
|
345 | }
|
346 | function resolveElementFromTarget(target) {
|
347 | switch (target) {
|
348 | case 'body':
|
349 | return document.body;
|
350 | case 'document':
|
351 | return document;
|
352 | case 'window':
|
353 | return window;
|
354 | default:
|
355 | return target;
|
356 | }
|
357 | }
|
358 | function parseTriggerCallbackName(triggerName) {
|
359 | const dotIndex = triggerName.indexOf('.');
|
360 | const trigger = triggerName.substring(0, dotIndex);
|
361 | const phase = triggerName.substr(dotIndex + 1);
|
362 | return [trigger, phase];
|
363 | }
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 | class InjectableAnimationEngine extends ɵAnimationEngine {
|
373 | constructor(doc, driver, normalizer) {
|
374 | super(doc.body, driver, normalizer);
|
375 | }
|
376 | ngOnDestroy() {
|
377 | this.flush();
|
378 | }
|
379 | }
|
380 | InjectableAnimationEngine.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: InjectableAnimationEngine, deps: [{ token: DOCUMENT }, { token: i1.AnimationDriver }, { token: i1.ɵAnimationStyleNormalizer }], target: i0.ɵɵFactoryTarget.Injectable });
|
381 | InjectableAnimationEngine.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: InjectableAnimationEngine });
|
382 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: InjectableAnimationEngine, decorators: [{
|
383 | type: Injectable
|
384 | }], ctorParameters: function () {
|
385 | return [{ type: undefined, decorators: [{
|
386 | type: Inject,
|
387 | args: [DOCUMENT]
|
388 | }] }, { type: i1.AnimationDriver }, { type: i1.ɵAnimationStyleNormalizer }];
|
389 | } });
|
390 | function instantiateSupportedAnimationDriver() {
|
391 | return ɵsupportsWebAnimations() ? new ɵWebAnimationsDriver() : new ɵCssKeyframesDriver();
|
392 | }
|
393 | function instantiateDefaultStyleNormalizer() {
|
394 | return new ɵWebAnimationsStyleNormalizer();
|
395 | }
|
396 | function instantiateRendererFactory(renderer, engine, zone) {
|
397 | return new AnimationRendererFactory(renderer, engine, zone);
|
398 | }
|
399 |
|
400 |
|
401 |
|
402 | const ANIMATION_MODULE_TYPE = new InjectionToken('AnimationModuleType');
|
403 | const SHARED_ANIMATION_PROVIDERS = [
|
404 | { provide: AnimationBuilder, useClass: BrowserAnimationBuilder },
|
405 | { provide: ɵAnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer },
|
406 | { provide: ɵAnimationEngine, useClass: InjectableAnimationEngine }, {
|
407 | provide: RendererFactory2,
|
408 | useFactory: instantiateRendererFactory,
|
409 | deps: [ɵDomRendererFactory2, ɵAnimationEngine, NgZone]
|
410 | }
|
411 | ];
|
412 |
|
413 |
|
414 |
|
415 |
|
416 | const BROWSER_ANIMATIONS_PROVIDERS = [
|
417 | { provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver },
|
418 | { provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations' }, ...SHARED_ANIMATION_PROVIDERS
|
419 | ];
|
420 |
|
421 |
|
422 |
|
423 |
|
424 | const BROWSER_NOOP_ANIMATIONS_PROVIDERS = [
|
425 | { provide: AnimationDriver, useClass: ɵNoopAnimationDriver },
|
426 | { provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' }, ...SHARED_ANIMATION_PROVIDERS
|
427 | ];
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 | class BrowserAnimationsModule {
|
442 | |
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | static withConfig(config) {
|
459 | return {
|
460 | ngModule: BrowserAnimationsModule,
|
461 | providers: config.disableAnimations ? BROWSER_NOOP_ANIMATIONS_PROVIDERS :
|
462 | BROWSER_ANIMATIONS_PROVIDERS
|
463 | };
|
464 | }
|
465 | }
|
466 | BrowserAnimationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
467 | BrowserAnimationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationsModule, exports: [BrowserModule] });
|
468 | BrowserAnimationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationsModule, providers: BROWSER_ANIMATIONS_PROVIDERS, imports: [BrowserModule] });
|
469 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserAnimationsModule, decorators: [{
|
470 | type: NgModule,
|
471 | args: [{
|
472 | exports: [BrowserModule],
|
473 | providers: BROWSER_ANIMATIONS_PROVIDERS,
|
474 | }]
|
475 | }] });
|
476 |
|
477 |
|
478 |
|
479 |
|
480 | class NoopAnimationsModule {
|
481 | }
|
482 | NoopAnimationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NoopAnimationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
483 | NoopAnimationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NoopAnimationsModule, exports: [BrowserModule] });
|
484 | NoopAnimationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NoopAnimationsModule, providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, imports: [BrowserModule] });
|
485 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NoopAnimationsModule, decorators: [{
|
486 | type: NgModule,
|
487 | args: [{
|
488 | exports: [BrowserModule],
|
489 | providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS,
|
490 | }]
|
491 | }] });
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 | export { ANIMATION_MODULE_TYPE, BrowserAnimationsModule, NoopAnimationsModule, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, BrowserAnimationFactory as ɵBrowserAnimationFactory, InjectableAnimationEngine as ɵInjectableAnimationEngine };
|
530 |
|