| /** |
| * @license Angular v5.2.0 |
| * (c) 2010-2018 Google, Inc. https://angular.io/ |
| * License: MIT |
| */ |
| import { Inject, Injectable, NgModule, NgZone, RendererFactory2, ViewEncapsulation } from '@angular/core'; |
| import { BrowserModule, DOCUMENT, ɵDomRendererFactory2 } from '@angular/platform-browser'; |
| import { AnimationBuilder, AnimationFactory, sequence } from '@angular/animations'; |
| import { AnimationDriver, ɵAnimationEngine, ɵAnimationStyleNormalizer, ɵNoopAnimationDriver, ɵWebAnimationsDriver, ɵWebAnimationsStyleNormalizer, ɵsupportsWebAnimations } from '@angular/animations/browser'; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| class BrowserAnimationBuilder extends AnimationBuilder { |
| /** |
| * @param {?} rootRenderer |
| * @param {?} doc |
| */ |
| constructor(rootRenderer, doc) { |
| super(); |
| this._nextAnimationId = 0; |
| const /** @type {?} */ typeData = /** @type {?} */ ({ |
| id: '0', |
| encapsulation: ViewEncapsulation.None, |
| styles: [], |
| data: { animation: [] } |
| }); |
| this._renderer = /** @type {?} */ (rootRenderer.createRenderer(doc.body, typeData)); |
| } |
| /** |
| * @param {?} animation |
| * @return {?} |
| */ |
| build(animation) { |
| const /** @type {?} */ id = this._nextAnimationId.toString(); |
| this._nextAnimationId++; |
| const /** @type {?} */ 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); |
| } |
| /** |
| * @param {?} eventName |
| * @param {?} callback |
| * @return {?} |
| */ |
| _listen(eventName, callback) { |
| return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback); |
| } |
| /** |
| * @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} checked by tsc |
| */ |
| const ANIMATION_PREFIX = '@'; |
| 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; |
| engine.onRemovalComplete = (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) { |
| const /** @type {?} */ EMPTY_NAMESPACE_ID = ''; |
| // cache the delegates to find out which cached delegate can |
| // be used by which cached renderer |
| const /** @type {?} */ delegate = this.delegate.createRenderer(hostElement, type); |
| if (!hostElement || !type || !type.data || !type.data['animation']) { |
| let /** @type {?} */ 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; |
| } |
| const /** @type {?} */ componentId = type.id; |
| const /** @type {?} */ namespaceId = type.id + '-' + this._currentId; |
| this._currentId++; |
| this.engine.register(namespaceId, hostElement); |
| const /** @type {?} */ animationTriggers = /** @type {?} */ (type.data['animation']); |
| animationTriggers.forEach(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(); |
| } |
| } |
| /** |
| * @return {?} |
| */ |
| _scheduleCountTask() { |
| Zone.current.scheduleMicroTask('incremenet the animation microtask', () => this._microtaskId++); |
| } |
| /** |
| * @param {?} count |
| * @param {?} fn |
| * @param {?} data |
| * @return {?} |
| */ |
| scheduleListenerCallback(count, fn, data) { |
| if (count >= 0 && count < this._microtaskId) { |
| this._zone.run(() => fn(data)); |
| return; |
| } |
| if (this._animationCallbacksBuffer.length == 0) { |
| Promise.resolve(null).then(() => { |
| this._zone.run(() => { |
| this._animationCallbacksBuffer.forEach(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 insted has inserted it |
| if (this._cdRecurDepth == 0) { |
| this._zone.runOutsideAngular(() => { |
| 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 ? (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 |
| * @return {?} |
| */ |
| removeChild(parent, oldChild) { |
| this.engine.onRemove(this.namespaceId, oldChild, this.delegate); |
| } |
| /** |
| * @param {?} selectorOrNode |
| * @return {?} |
| */ |
| selectRootElement(selectorOrNode) { return this.delegate.selectRootElement(selectorOrNode); } |
| /** |
| * @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); |
| } |
| /** |
| * @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) { |
| const /** @type {?} */ element = resolveElementFromTarget(target); |
| let /** @type {?} */ name = eventName.substr(1); |
| let /** @type {?} */ 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, event => { |
| const /** @type {?} */ 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) { |
| const /** @type {?} */ dotIndex = triggerName.indexOf('.'); |
| const /** @type {?} */ trigger = triggerName.substring(0, dotIndex); |
| const /** @type {?} */ phase = triggerName.substr(dotIndex + 1); |
| return [trigger, phase]; |
| } |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| /** |
| * @license |
| * Copyright Google Inc. All Rights Reserved. |
| * |
| * Use of this source code is governed by an MIT-style license that can be |
| * found in the LICENSE file at https://angular.io/license |
| */ |
| class InjectableAnimationEngine extends ɵAnimationEngine { |
| /** |
| * @param {?} driver |
| * @param {?} normalizer |
| */ |
| constructor(driver, normalizer) { |
| super(driver, normalizer); |
| } |
| } |
| InjectableAnimationEngine.decorators = [ |
| { type: Injectable }, |
| ]; |
| /** @nocollapse */ |
| InjectableAnimationEngine.ctorParameters = () => [ |
| { type: AnimationDriver, }, |
| { type: ɵAnimationStyleNormalizer, }, |
| ]; |
| /** |
| * @return {?} |
| */ |
| function instantiateSupportedAnimationDriver() { |
| if (ɵsupportsWebAnimations()) { |
| return new ɵWebAnimationsDriver(); |
| } |
| return new ɵNoopAnimationDriver(); |
| } |
| /** |
| * @return {?} |
| */ |
| function instantiateDefaultStyleNormalizer() { |
| return new ɵWebAnimationsStyleNormalizer(); |
| } |
| /** |
| * @param {?} renderer |
| * @param {?} engine |
| * @param {?} zone |
| * @return {?} |
| */ |
| function instantiateRendererFactory(renderer, engine, zone) { |
| return new AnimationRendererFactory(renderer, engine, zone); |
| } |
| 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. |
| */ |
| const BROWSER_ANIMATIONS_PROVIDERS = [ |
| { provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver }, |
| ...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. |
| */ |
| const BROWSER_NOOP_ANIMATIONS_PROVIDERS = [{ provide: AnimationDriver, useClass: ɵNoopAnimationDriver }, ...SHARED_ANIMATION_PROVIDERS]; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| /** |
| * \@experimental Animation support is experimental. |
| */ |
| class BrowserAnimationsModule { |
| } |
| BrowserAnimationsModule.decorators = [ |
| { type: NgModule, args: [{ |
| exports: [BrowserModule], |
| providers: BROWSER_ANIMATIONS_PROVIDERS, |
| },] }, |
| ]; |
| /** @nocollapse */ |
| BrowserAnimationsModule.ctorParameters = () => []; |
| /** |
| * \@experimental Animation support is experimental. |
| */ |
| class NoopAnimationsModule { |
| } |
| NoopAnimationsModule.decorators = [ |
| { type: NgModule, args: [{ |
| exports: [BrowserModule], |
| providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS, |
| },] }, |
| ]; |
| /** @nocollapse */ |
| NoopAnimationsModule.ctorParameters = () => []; |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| /** |
| * @license |
| * Copyright Google Inc. All Rights Reserved. |
| * |
| * Use of this source code is governed by an MIT-style license that can be |
| * found in the LICENSE file at https://angular.io/license |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| /** |
| * @license |
| * Copyright Google Inc. All Rights Reserved. |
| * |
| * Use of this source code is governed by an MIT-style license that can be |
| * found in the LICENSE file at https://angular.io/license |
| */ |
| /** |
| * @module |
| * @description |
| * Entry point for all public APIs of this package. |
| */ |
| |
| /** |
| * @fileoverview added by tsickle |
| * @suppress {checkTypes} checked by tsc |
| */ |
| /** |
| * Generated bundle index. Do not edit. |
| */ |
| |
| export { BrowserAnimationsModule, NoopAnimationsModule, BrowserAnimationBuilder as ɵBrowserAnimationBuilder, BrowserAnimationFactory as ɵBrowserAnimationFactory, AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory, BaseAnimationRenderer as ɵa, BROWSER_ANIMATIONS_PROVIDERS as ɵf, BROWSER_NOOP_ANIMATIONS_PROVIDERS as ɵg, InjectableAnimationEngine as ɵb, instantiateDefaultStyleNormalizer as ɵd, instantiateRendererFactory as ɵe, instantiateSupportedAnimationDriver as ɵc }; |
| //# sourceMappingURL=animations.js.map |