Skip to content

Commit

Permalink
Added onTick event to animations.
Browse files Browse the repository at this point in the history
  • Loading branch information
michielvandergeest committed Oct 15, 2024
1 parent 9c01b8b commit 623e96e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/animations/CoreAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ export class CoreAnimation extends EventEmitter {
}
}

if (this.progress < 1) {
this.emit('tick', {});
}

if (this.progress === 1) {
this.emit('finished', {});
}
Expand Down
7 changes: 7 additions & 0 deletions src/core/animations/CoreAnimationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class CoreAnimationController
// Bind event handlers
this.onAnimating = this.onAnimating.bind(this);
this.onFinished = this.onFinished.bind(this);
this.onTick = this.onTick.bind(this);
}

start(): IAnimationController {
Expand Down Expand Up @@ -93,6 +94,7 @@ export class CoreAnimationController
// Hook up event listeners
this.animation.once('finished', this.onFinished);
this.animation.on('animating', this.onAnimating);
this.animation.on('tick', this.onTick);
// Then register the animation
this.manager.registerAnimation(this.animation);
}
Expand All @@ -103,6 +105,7 @@ export class CoreAnimationController
// Then unhook event listeners
this.animation.off('finished', this.onFinished);
this.animation.off('animating', this.onAnimating);
this.animation.off('tick', this.onTick);
}

private makeStoppedPromise(): void {
Expand Down Expand Up @@ -142,4 +145,8 @@ export class CoreAnimationController
this.state = 'running';
this.emit('animating', this);
}

private onTick(this: CoreAnimationController): void {
this.emit('tick');
}
}

0 comments on commit 623e96e

Please sign in to comment.