package.esm2022.src.players.animation_group_player.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of animations Show documentation
Show all versions of animations Show documentation
Angular - animations integration with web-animations
/**
* @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
*/
/**
* A programmatic controller for a group of reusable animations.
* Used internally to control animations.
*
* @see {@link AnimationPlayer}
* @see {@link animations/group group}
*
*/
export class AnimationGroupPlayer {
constructor(_players) {
this._onDoneFns = [];
this._onStartFns = [];
this._finished = false;
this._started = false;
this._destroyed = false;
this._onDestroyFns = [];
this.parentPlayer = null;
this.totalTime = 0;
this.players = _players;
let doneCount = 0;
let destroyCount = 0;
let startCount = 0;
const total = this.players.length;
if (total == 0) {
queueMicrotask(() => this._onFinish());
}
else {
this.players.forEach((player) => {
player.onDone(() => {
if (++doneCount == total) {
this._onFinish();
}
});
player.onDestroy(() => {
if (++destroyCount == total) {
this._onDestroy();
}
});
player.onStart(() => {
if (++startCount == total) {
this._onStart();
}
});
});
}
this.totalTime = this.players.reduce((time, player) => Math.max(time, player.totalTime), 0);
}
_onFinish() {
if (!this._finished) {
this._finished = true;
this._onDoneFns.forEach((fn) => fn());
this._onDoneFns = [];
}
}
init() {
this.players.forEach((player) => player.init());
}
onStart(fn) {
this._onStartFns.push(fn);
}
_onStart() {
if (!this.hasStarted()) {
this._started = true;
this._onStartFns.forEach((fn) => fn());
this._onStartFns = [];
}
}
onDone(fn) {
this._onDoneFns.push(fn);
}
onDestroy(fn) {
this._onDestroyFns.push(fn);
}
hasStarted() {
return this._started;
}
play() {
if (!this.parentPlayer) {
this.init();
}
this._onStart();
this.players.forEach((player) => player.play());
}
pause() {
this.players.forEach((player) => player.pause());
}
restart() {
this.players.forEach((player) => player.restart());
}
finish() {
this._onFinish();
this.players.forEach((player) => player.finish());
}
destroy() {
this._onDestroy();
}
_onDestroy() {
if (!this._destroyed) {
this._destroyed = true;
this._onFinish();
this.players.forEach((player) => player.destroy());
this._onDestroyFns.forEach((fn) => fn());
this._onDestroyFns = [];
}
}
reset() {
this.players.forEach((player) => player.reset());
this._destroyed = false;
this._finished = false;
this._started = false;
}
setPosition(p) {
const timeAtPosition = p * this.totalTime;
this.players.forEach((player) => {
const position = player.totalTime ? Math.min(1, timeAtPosition / player.totalTime) : 1;
player.setPosition(position);
});
}
getPosition() {
const longestPlayer = this.players.reduce((longestSoFar, player) => {
const newPlayerIsLongest = longestSoFar === null || player.totalTime > longestSoFar.totalTime;
return newPlayerIsLongest ? player : longestSoFar;
}, null);
return longestPlayer != null ? longestPlayer.getPosition() : 0;
}
beforeDestroy() {
this.players.forEach((player) => {
if (player.beforeDestroy) {
player.beforeDestroy();
}
});
}
/** @internal */
triggerCallback(phaseName) {
const methods = phaseName == 'start' ? this._onStartFns : this._onDoneFns;
methods.forEach((fn) => fn());
methods.length = 0;
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5pbWF0aW9uX2dyb3VwX3BsYXllci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2FuaW1hdGlvbnMvc3JjL3BsYXllcnMvYW5pbWF0aW9uX2dyb3VwX3BsYXllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFJSDs7Ozs7OztHQU9HO0FBQ0gsTUFBTSxPQUFPLG9CQUFvQjtJQVkvQixZQUFZLFFBQTJCO1FBWC9CLGVBQVUsR0FBZSxFQUFFLENBQUM7UUFDNUIsZ0JBQVcsR0FBZSxFQUFFLENBQUM7UUFDN0IsY0FBUyxHQUFHLEtBQUssQ0FBQztRQUNsQixhQUFRLEdBQUcsS0FBSyxDQUFDO1FBQ2pCLGVBQVUsR0FBRyxLQUFLLENBQUM7UUFDbkIsa0JBQWEsR0FBZSxFQUFFLENBQUM7UUFF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