/** * @license * Copyright Google LLC 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 */ import { AnimationBuilder, AnimationFactory, sequence } from '@angular/animations'; import { DOCUMENT } from '@angular/common'; import { Inject, Injectable, RendererFactory2, ViewEncapsulation } from '@angular/core'; import * as i0 from "@angular/core"; export class BrowserAnimationBuilder extends AnimationBuilder { constructor(rootRenderer, doc) { super(); this._nextAnimationId = 0; const typeData = { id: '0', encapsulation: ViewEncapsulation.None, styles: [], data: { animation: [] } }; this._renderer = rootRenderer.createRenderer(doc.body, typeData); } build(animation) { const id = this._nextAnimationId.toString(); this._nextAnimationId++; const entry = Array.isArray(animation) ? sequence(animation) : animation; issueAnimationCommand(this._renderer, null, id, 'register', [entry]); return new BrowserAnimationFactory(id, this._renderer); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BrowserAnimationBuilder, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BrowserAnimationBuilder }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BrowserAnimationBuilder, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: i0.RendererFactory2 }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] }]; } }); export class BrowserAnimationFactory extends AnimationFactory { constructor(_id, _renderer) { super(); this._id = _id; this._renderer = _renderer; } create(element, options) { return new RendererAnimationPlayer(this._id, element, options || {}, this._renderer); } } export class RendererAnimationPlayer { 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); } _listen(eventName, callback) { return this._renderer.listen(this.element, `@@${this.id}:${eventName}`, callback); } _command(command, ...args) { return issueAnimationCommand(this._renderer, this.element, this.id, command, args); } onDone(fn) { this._listen('done', fn); } onStart(fn) { this._listen('start', fn); } onDestroy(fn) { this._listen('destroy', fn); } init() { this._command('init'); } hasStarted() { return this._started; } play() { this._command('play'); this._started = true; } pause() { this._command('pause'); } restart() { this._command('restart'); } finish() { this._command('finish'); } destroy() { this._command('destroy'); } reset() { this._command('reset'); this._started = false; } setPosition(p) { this._command('setPosition', p); } getPosition() { return this._renderer.engine.players[+this.id]?.getPosition() ?? 0; } } function issueAnimationCommand(renderer, element, id, command, args) { return renderer.setProperty(element, `@@${id}:${command}`, args); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5pbWF0aW9uX2J1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9wbGF0Zm9ybS1icm93c2VyL2FuaW1hdGlvbnMvc3JjL2FuaW1hdGlvbl9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUNILE9BQU8sRUFBQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFBd0QsUUFBUSxFQUFDLE1BQU0scUJBQXFCLENBQUM7QUFDdkksT0FBTyxFQUFDLFFBQVEsRUFBQyxNQUFNLGlCQUFpQixDQUFDO0FBQ3pDLE9BQU8sRUFBQyxNQUFNLEVBQUUsVUFBVSxFQUFFLGdCQUFnQixFQUFpQixpQkFBaUIsRUFBQyxNQUFNLGVBQWUsQ0FBQzs7QUFLckcsTUFBTSxPQUFPLHVCQUF3QixTQUFRLGdCQUFnQjtJQUkzRCxZQUFZLFlBQThCLEVBQW9CLEdBQVE7UUFDcEUsS0FBSyxFQUFFLENBQUM7UUFKRixxQkFBZ0IsR0FBRyxDQUFDLENBQUM7UUFLM0IsTUFBTSxRQUFRLEdBQ1YsRUFBQyxFQUFFLEVBQUUsR0FBRyxFQUFFL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