Skip to content

Commit

Permalink
Don't run last animation frame
Browse files Browse the repository at this point in the history
  • Loading branch information
plegner committed Aug 21, 2023
1 parent 966d1e5 commit 506cd71
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function animate(callback: AnimationCallback, duration?: number): Animati
};

function getFrame() {
if (running && (!duration || lastTime <= duration)) {
if (!running) return;
if (!duration || lastTime <= duration) {
window.requestAnimationFrame(getFrame);
}

Expand Down

0 comments on commit 506cd71

Please sign in to comment.