source: trip-planner-front/node_modules/@angular/platform-browser/fesm2015/animations.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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