| /** |
| * @license Angular v8.1.1 |
| * (c) 2010-2019 Google LLC. https://angular.io/ |
| * License: MIT |
| */ |
| |
| import { ViewEncapsulation, Injectable, RendererFactory2, Inject, NgZone, InjectionToken, NgModule } from '@angular/core'; |
| import { ɵDomRendererFactory2, BrowserModule } from '@angular/platform-browser'; |
| import { AnimationBuilder, sequence, AnimationFactory } from '@angular/animations'; |
| import { ɵAnimationEngine, AnimationDriver, ɵAnimationStyleNormalizer, ɵsupportsWebAnimations, ɵWebAnimationsDriver, ɵCssKeyframesDriver, ɵWebAnimationsStyleNormalizer, ɵNoopAnimationDriver } from '@angular/animations/browser'; |
| import { DOCUMENT } from '@angular/common'; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class BrowserAnimationBuilder extends AnimationBuilder { |
| /** |
| * @param {?} rootRenderer |
| * @param {?} doc |
| */ |
| constructor(rootRenderer, doc) { |
| super(); |
| this._nextAnimationId = 0; |
| /** @type {?} */ |
| const typeData = (/** @type {?} */ ({ |
| id: '0', |
| encapsulation: ViewEncapsulation.None, |
| styles: [], |
| data: { animation: [] } |
| })); |
| this._renderer = (/** @type {?} */ (rootRenderer.createRenderer(doc.body, typeData))); |
| } |
| /** |
| * @param {?} animation |
| * @return {?} |
| */ |
| build(animation) { |
| /** @type {?} */ |
| const id = this._nextAnimationId.toString(); |
| this._nextAnimationId++; |
| /** @type {?} */ |
| const entry = Array.isArray(animation) ? sequence(animation) : animation; |
| issueAnimationCommand(this._renderer, null, id, 'register', [entry]); |
| return new BrowserAnimationFactory(id, this._renderer); |
| } |
| } |
| BrowserAnimationBuilder.decorators = [ |
| { type: Injectable } |
| ]; |
| /** @nocollapse */ |
| BrowserAnimationBuilder.ctorParameters = () => [ |
| { type: RendererFactory2 }, |
| { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] } |
| ]; |
| class BrowserAnimationFactory extends AnimationFactory { |
| /** |
| * @param {?} _id |
| * @param {?} _renderer |
| */ |
| constructor(_id, _renderer) { |
| super(); |
| this._id = _id; |
| this._renderer = _renderer; |
| } |
| /** |
| * @param {?} element |
| * @param {?=} options |
| * @return {?} |
| */ |
| create(element, options) { |
| return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer); |
| } |
| } |
| class RendererAnimationPlayer { |
| /** |
| * @param {?} id |
| * @param {?} element |
| * @param {?} options |
| * @param {?} _renderer |
| */ |
| constructor(id, element, options, _renderer) { |
| this.id = id; |
| this.element = element; |
| this._renderer = _renderer; |
| this.parentPlayer = null; |
| this._started = false; |
| this.totalTime = 0; |
| this._command('create', options); |
| } |
| /** |
| * @private |
| * @param {?} eventName |
| * @param {?} callback |
| * @return {?} |
| */ |
| _listen(eventName, callback) { |
| return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback); |
| } |
| /** |
| * @private |
| * @param {?} command |
| * @param {...?} args |
| * @return {?} |
| */ |
| _command(command, ...args) { |
| return issueAnimationCommand(this._renderer, this.element, this.id, command, args); |
| } |
| /** |
| * @param {?} fn |
| * @return {?} |
| */ |
| onDone(fn) { this._listen('done', fn); } |
| /** |
| * @param {?} fn |
| * @return {?} |
| */ |
| onStart(fn) { this._listen('start', fn); } |
| /** |
| * @param {?} fn |
| * @return {?} |
| */ |
| onDestroy(fn) { this._listen('destroy', fn); } |
| /** |
| * @return {?} |
| */ |
| init() { this._command('init'); } |
| /** |
| * @return {?} |
| */ |
| hasStarted() { return this._started; } |
| /** |
| * @return {?} |
| */ |
| play() { |
| this._command('play'); |
| this._started = true; |
| } |
| /** |
| * @return {?} |
| */ |
| pause() { this._command('pause'); } |
| /** |
| * @return {?} |
| */ |
| restart() { this._command('restart'); } |
| /** |
| * @return {?} |
| */ |
| finish() { this._command('finish'); } |
| /** |
| * @return {?} |
| */ |
| destroy() { this._command('destroy'); } |
| /** |
| * @return {?} |
| */ |
| reset() { this._command('reset'); } |
| /** |
| * @param {?} p |
| * @return {?} |
| */ |
| setPosition(p) { this._command('setPosition', p); } |
| /** |
| * @return {?} |
| */ |
| getPosition() { return 0; } |
| } |
| /** |
| * @param {?} renderer |
| * @param {?} element |
| * @param {?} id |
| * @param {?} command |
| * @param {?} args |
| * @return {?} |
| */ |
| function issueAnimationCommand(renderer, element, id, command, args) { |
| return renderer.setProperty(element, `@@${id}:${command}`, args); |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** @type {?} */ |
| const ANIMATION_PREFIX = '@'; |
| /** @type {?} */ |
| const DISABLE_ANIMATIONS_FLAG = '@.disabled'; |
| class AnimationRendererFactory { |
| /** |
| * @param {?} delegate |
| * @param {?} engine |
| * @param {?} _zone |
| */ |
| constructor(delegate, engine, _zone) { |
| this.delegate = delegate; |
| this.engine = engine; |
| this._zone = _zone; |
| this._currentId = 0; |
| this._microtaskId = 1; |
| this._animationCallbacksBuffer = []; |
| this._rendererCache = new Map(); |
| this._cdRecurDepth = 0; |
| this.promise = Promise.resolve(0); |
| engine.onRemovalComplete = (/** |
| * @param {?} element |
| * @param {?} delegate |
| * @return {?} |
| */ |
| (element, delegate) => { |
| // Note: if an component element has a leave animation, and the component |
| // a host leave animation, the view engine will call `removeChild` for the parent |
| // component renderer as well as for the child component renderer. |
| // Therefore, we need to check if we already removed the element. |
| if (delegate && delegate.parentNode(element)) { |
| delegate.removeChild(element.parentNode, element); |
| } |
| }); |
| } |
| /** |
| * @param {?} hostElement |
| * @param {?} type |
| * @return {?} |
| */ |
| createRenderer(hostElement, type) { |
| /** @type {?} */ |
| const EMPTY_NAMESPACE_ID = ''; |
| // cache the delegates to find out which cached delegate can |
| // be used by which cached renderer |
| /** @type {?} */ |
| const delegate = this.delegate.createRenderer(hostElement, type); |
| if (!hostElement || !type || !type.data || !type.data['animation']) { |
| /** @type {?} */ |
| let renderer = this._rendererCache.get(delegate); |
| if (!renderer) { |
| renderer = new BaseAnimationRenderer(EMPTY_NAMESPACE_ID, delegate, this.engine); |
| // only cache this result when the base renderer is used |
| this._rendererCache.set(delegate, renderer); |
| } |
| return renderer; |
| } |
| /** @type {?} */ |
| const componentId = type.id; |
| /** @type {?} */ |
| const namespaceId = type.id + '-' + this._currentId; |
| this._currentId++; |
| this.engine.register(namespaceId, hostElement); |
| /** @type {?} */ |
| const animationTriggers = (/** @type {?} */ (type.data['animation'])); |
| animationTriggers.forEach((/** |
| * @param {?} trigger |
| * @return {?} |
| */ |
| trigger => this.engine.registerTrigger(componentId, namespaceId, hostElement, trigger.name, trigger))); |
| return new AnimationRenderer(this, namespaceId, delegate, this.engine); |
| } |
| /** |
| * @return {?} |
| */ |
| begin() { |
| this._cdRecurDepth++; |
| if (this.delegate.begin) { |
| this.delegate.begin(); |
| } |
| } |
| /** |
| * @private |
| * @return {?} |
| */ |
| _scheduleCountTask() { |
| // always use promise to schedule microtask instead of use Zone |
| this.promise.then((/** |
| * @return {?} |
| */ |
| () => { this._microtaskId++; })); |
| } |
| /** |
| * \@internal |
| * @param {?} count |
| * @param {?} fn |
| * @param {?} data |
| * @return {?} |
| */ |
| scheduleListenerCallback(count, fn, data) { |
| if (count >= 0 && count < this._microtaskId) { |
| this._zone.run((/** |
| * @return {?} |
| */ |
| () => fn(data))); |
| return; |
| } |
| if (this._animationCallbacksBuffer.length == 0) { |
| Promise.resolve(null).then((/** |
| * @return {?} |
| */ |
| () => { |
| this._zone.run((/** |
| * @return {?} |
| */ |
| () => { |
| this._animationCallbacksBuffer.forEach((/** |
| * @param {?} tuple |
| * @return {?} |
| */ |
| tuple => { |
| const [fn, data] = tuple; |
| fn(data); |
| })); |
| this._animationCallbacksBuffer = []; |
| })); |
| })); |
| } |
| this._animationCallbacksBuffer.push([fn, data]); |
| } |
| /** |
| * @return {?} |
| */ |
| end() { |
| this._cdRecurDepth--; |
| // this is to prevent animations from running twice when an inner |
| // component does CD when a parent component instead has inserted it |
| if (this._cdRecurDepth == 0) { |
| this._zone.runOutsideAngular((/** |
| * @return {?} |
| */ |
| () => { |
| this._scheduleCountTask(); |
| this.engine.flush(this._microtaskId); |
| })); |
| } |
| if (this.delegate.end) { |
| this.delegate.end(); |
| } |
| } |
| /** |
| * @return {?} |
| */ |
| whenRenderingDone() { return this.engine.whenRenderingDone(); } |
| } |
| AnimationRendererFactory.decorators = [ |
| { type: Injectable } |
| ]; |
| /** @nocollapse */ |
| AnimationRendererFactory.ctorParameters = () => [ |
| { type: RendererFactory2 }, |
| { type: ɵAnimationEngine }, |
| { type: NgZone } |
| ]; |
| class BaseAnimationRenderer { |
| /** |
| * @param {?} namespaceId |
| * @param {?} delegate |
| * @param {?} engine |
| */ |
| constructor(namespaceId, delegate, engine) { |
| this.namespaceId = namespaceId; |
| this.delegate = delegate; |
| this.engine = engine; |
| this.destroyNode = this.delegate.destroyNode ? (/** |
| * @param {?} n |
| * @return {?} |
| */ |
| (n) => (/** @type {?} */ (delegate.destroyNode))(n)) : null; |
| } |
| /** |
| * @return {?} |
| */ |
| get data() { return this.delegate.data; } |
| /** |
| * @return {?} |
| */ |
| destroy() { |
| this.engine.destroy(this.namespaceId, this.delegate); |
| this.delegate.destroy(); |
| } |
| /** |
| * @param {?} name |
| * @param {?=} namespace |
| * @return {?} |
| */ |
| createElement(name, namespace) { |
| return this.delegate.createElement(name, namespace); |
| } |
| /** |
| * @param {?} value |
| * @return {?} |
| */ |
| createComment(value) { return this.delegate.createComment(value); } |
| /** |
| * @param {?} value |
| * @return {?} |
| */ |
| createText(value) { return this.delegate.createText(value); } |
| /** |
| * @param {?} parent |
| * @param {?} newChild |
| * @return {?} |
| */ |
| appendChild(parent, newChild) { |
| this.delegate.appendChild(parent, newChild); |
| this.engine.onInsert(this.namespaceId, newChild, parent, false); |
| } |
| /** |
| * @param {?} parent |
| * @param {?} newChild |
| * @param {?} refChild |
| * @return {?} |
| */ |
| insertBefore(parent, newChild, refChild) { |
| this.delegate.insertBefore(parent, newChild, refChild); |
| this.engine.onInsert(this.namespaceId, newChild, parent, true); |
| } |
| /** |
| * @param {?} parent |
| * @param {?} oldChild |
| * @param {?} isHostElement |
| * @return {?} |
| */ |
| removeChild(parent, oldChild, isHostElement) { |
| this.engine.onRemove(this.namespaceId, oldChild, this.delegate, isHostElement); |
| } |
| /** |
| * @param {?} selectorOrNode |
| * @param {?=} preserveContent |
| * @return {?} |
| */ |
| selectRootElement(selectorOrNode, preserveContent) { |
| return this.delegate.selectRootElement(selectorOrNode, preserveContent); |
| } |
| /** |
| * @param {?} node |
| * @return {?} |
| */ |
| parentNode(node) { return this.delegate.parentNode(node); } |
| /** |
| * @param {?} node |
| * @return {?} |
| */ |
| nextSibling(node) { return this.delegate.nextSibling(node); } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @param {?} value |
| * @param {?=} namespace |
| * @return {?} |
| */ |
| setAttribute(el, name, value, namespace) { |
| this.delegate.setAttribute(el, name, value, namespace); |
| } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @param {?=} namespace |
| * @return {?} |
| */ |
| removeAttribute(el, name, namespace) { |
| this.delegate.removeAttribute(el, name, namespace); |
| } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @return {?} |
| */ |
| addClass(el, name) { this.delegate.addClass(el, name); } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @return {?} |
| */ |
| removeClass(el, name) { this.delegate.removeClass(el, name); } |
| /** |
| * @param {?} el |
| * @param {?} style |
| * @param {?} value |
| * @param {?=} flags |
| * @return {?} |
| */ |
| setStyle(el, style, value, flags) { |
| this.delegate.setStyle(el, style, value, flags); |
| } |
| /** |
| * @param {?} el |
| * @param {?} style |
| * @param {?=} flags |
| * @return {?} |
| */ |
| removeStyle(el, style, flags) { |
| this.delegate.removeStyle(el, style, flags); |
| } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @param {?} value |
| * @return {?} |
| */ |
| setProperty(el, name, value) { |
| if (name.charAt(0) == ANIMATION_PREFIX && name == DISABLE_ANIMATIONS_FLAG) { |
| this.disableAnimations(el, !!value); |
| } |
| else { |
| this.delegate.setProperty(el, name, value); |
| } |
| } |
| /** |
| * @param {?} node |
| * @param {?} value |
| * @return {?} |
| */ |
| setValue(node, value) { this.delegate.setValue(node, value); } |
| /** |
| * @param {?} target |
| * @param {?} eventName |
| * @param {?} callback |
| * @return {?} |
| */ |
| listen(target, eventName, callback) { |
| return this.delegate.listen(target, eventName, callback); |
| } |
| /** |
| * @protected |
| * @param {?} element |
| * @param {?} value |
| * @return {?} |
| */ |
| disableAnimations(element, value) { |
| this.engine.disableAnimations(element, value); |
| } |
| } |
| class AnimationRenderer extends BaseAnimationRenderer { |
| /** |
| * @param {?} factory |
| * @param {?} namespaceId |
| * @param {?} delegate |
| * @param {?} engine |
| */ |
| constructor(factory, namespaceId, delegate, engine) { |
| super(namespaceId, delegate, engine); |
| this.factory = factory; |
| this.namespaceId = namespaceId; |
| } |
| /** |
| * @param {?} el |
| * @param {?} name |
| * @param {?} value |
| * @return {?} |
| */ |
| setProperty(el, name, value) { |
| if (name.charAt(0) == ANIMATION_PREFIX) { |
| if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) { |
| value = value === undefined ? true : !!value; |
| this.disableAnimations(el, (/** @type {?} */ (value))); |
| } |
| else { |
| this.engine.process(this.namespaceId, el, name.substr(1), value); |
| } |
| } |
| else { |
| this.delegate.setProperty(el, name, value); |
| } |
| } |
| /** |
| * @param {?} target |
| * @param {?} eventName |
| * @param {?} callback |
| * @return {?} |
| */ |
| listen(target, eventName, callback) { |
| if (eventName.charAt(0) == ANIMATION_PREFIX) { |
| /** @type {?} */ |
| const element = resolveElementFromTarget(target); |
| /** @type {?} */ |
| let name = eventName.substr(1); |
| /** @type {?} */ |
| let phase = ''; |
| // @listener.phase is for trigger animation callbacks |
| // @@listener is for animation builder callbacks |
| if (name.charAt(0) != ANIMATION_PREFIX) { |
| [name, phase] = parseTriggerCallbackName(name); |
| } |
| return this.engine.listen(this.namespaceId, element, name, phase, (/** |
| * @param {?} event |
| * @return {?} |
| */ |
| event => { |
| /** @type {?} */ |
| const countId = ((/** @type {?} */ (event)))['_data'] || -1; |
| this.factory.scheduleListenerCallback(countId, callback, event); |
| })); |
| } |
| return this.delegate.listen(target, eventName, callback); |
| } |
| } |
| /** |
| * @param {?} target |
| * @return {?} |
| */ |
| function resolveElementFromTarget(target) { |
| switch (target) { |
| case 'body': |
| return document.body; |
| case 'document': |
| return document; |
| case 'window': |
| return window; |
| default: |
| return target; |
| } |
| } |
| /** |
| * @param {?} triggerName |
| * @return {?} |
| */ |
| function parseTriggerCallbackName(triggerName) { |
| /** @type {?} */ |
| const dotIndex = triggerName.indexOf('.'); |
| /** @type {?} */ |
| const trigger = triggerName.substring(0, dotIndex); |
| /** @type {?} */ |
| const phase = triggerName.substr(dotIndex + 1); |
| return [trigger, phase]; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| class InjectableAnimationEngine extends ɵAnimationEngine { |
| /** |
| * @param {?} doc |
| * @param {?} driver |
| * @param {?} normalizer |
| */ |
| constructor(doc, driver, normalizer) { |
| super(doc.body, driver, normalizer); |
| } |
| } |
| InjectableAnimationEngine.decorators = [ |
| { type: Injectable } |
| ]; |
| /** @nocollapse */ |
| InjectableAnimationEngine.ctorParameters = () => [ |
| { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }, |
| { type: AnimationDriver }, |
| { type: ɵAnimationStyleNormalizer } |
| ]; |
| /** |
| * @return {?} |
| */ |
| function instantiateSupportedAnimationDriver() { |
| return ɵsupportsWebAnimations() ? new ɵWebAnimationsDriver() : new ɵCssKeyframesDriver(); |
| } |
| /** |
| * @return {?} |
| */ |
| function instantiateDefaultStyleNormalizer() { |
| return new ɵWebAnimationsStyleNormalizer(); |
| } |
| /** |
| * @param {?} renderer |
| * @param {?} engine |
| * @param {?} zone |
| * @return {?} |
| */ |
| function instantiateRendererFactory(renderer, engine, zone) { |
| return new AnimationRendererFactory(renderer, engine, zone); |
| } |
| /** |
| * \@publicApi |
| * @type {?} |
| */ |
| const ANIMATION_MODULE_TYPE = new InjectionToken('AnimationModuleType'); |
| /** @type {?} */ |
| const SHARED_ANIMATION_PROVIDERS = [ |
| { provide: AnimationBuilder, useClass: BrowserAnimationBuilder }, |
| { provide: ɵAnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer }, |
| { provide: ɵAnimationEngine, useClass: InjectableAnimationEngine }, { |
| provide: RendererFactory2, |
| useFactory: instantiateRendererFactory, |
| deps: [ɵDomRendererFactory2, ɵAnimationEngine, NgZone] |
| } |
| ]; |
| /** |
| * Separate providers from the actual module so that we can do a local modification in Google3 to |
| * include them in the BrowserModule. |
| * @type {?} |
| */ |
| const BROWSER_ANIMATIONS_PROVIDERS = [ |
| { provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver }, |
| { provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations' }, ...SHARED_ANIMATION_PROVIDERS |
| ]; |
| /** |
| * Separate providers from the actual module so that we can do a local modification in Google3 to |
| * include them in the BrowserTestingModule. |
| * @type {?} |
| */ |
| const BROWSER_NOOP_ANIMATIONS_PROVIDERS = [ |
| { provide: AnimationDriver, useClass: ɵNoopAnimationDriver }, |
| { provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations' }, ...SHARED_ANIMATION_PROVIDERS |
| ]; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| /** |
| * Exports `BrowserModule` with additional [dependency-injection providers](guide/glossary#provider) |
| * for use with animations. See [Animations](guide/animations). |
| * \@publicApi |
| */ |
| class BrowserAnimationsModule { |
| } |
| BrowserAnimationsModule.decorators = [ |
| { type: NgModule, args: [{ |
| exports: [BrowserModule], |
| providers: BROWSER_ANIMATIONS_PROVIDERS, |
| },] } |
| ]; |
| /** |
| * A null player that must be imported to allow disabling of animations. |
| * \@publicApi |
| */ |
| class NoopAnimationsModule { |
| } |
| NoopAnimationsModule.decorators = [ |
| { type: NgModule, args: [{ |
| exports: [BrowserModule], |
| providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, |
| },] } |
| ]; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc |
| */ |
| |
| /** |
| * Generated bundle index. Do not edit. |
| */ |
| |
| export { BaseAnimationRenderer as ɵangular_packages_platform_browser_animations_animations_f, BROWSER_ANIMATIONS_PROVIDERS as ɵangular_packages_platform_browser_animations_animations_d, BROWSER_NOOP_ANIMATIONS_PROVIDERS as ɵangular_packages_platform_browser_animations_animations_e, instantiateDefaultStyleNormalizer as ɵangular_packages_platform_browser_animations_animations_b, instantiateRendererFactory as ɵangular_packages_platform_browser_animations_animations_c, instantiateSupportedAnimationDriver as ɵangular_packages_platform_browser_animations_animations_a, BrowserAnimationsModule, NoopAnimationsModule, ANIMATION_MODULE_TYPE, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, BrowserAnimationFactory as ɵBrowserAnimationFactory, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, InjectableAnimationEngine as ɵInjectableAnimationEngine }; |
| //# sourceMappingURL=animations.js.map |