From fbae35eb011b74dd7abf57149ada4d84849aea55 Mon Sep 17 00:00:00 2001 From: Sam Martin Date: Fri, 4 Oct 2024 11:07:56 -0700 Subject: [PATCH] handling animations that are wired up before clarity --- packages/clarity-js/src/layout/animation.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/clarity-js/src/layout/animation.ts b/packages/clarity-js/src/layout/animation.ts index cfebd1db..ffb0d637 100644 --- a/packages/clarity-js/src/layout/animation.ts +++ b/packages/clarity-js/src/layout/animation.ts @@ -36,6 +36,19 @@ export function start(): void { return createdAnimation; } } + if (document.getAnimations) { + for (var animation of document.getAnimations()) { + if (animation.playState === "finished") { + trackAnimationOperation(animation, "finish"); + } + else if (animation.playState === "paused" || animation.playState === "idle") { + trackAnimationOperation(animation, "pause"); + } + else if (animation.playState === "running") { + trackAnimationOperation(animation, "play"); + } + } + } } }