From 6f06b5e1e7c0f030c4e603b77b8da082d3b6ba9d Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] only add click animation when cast is not sync --- src/replay/index.ts | 46 +++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index ce1722a0..44cd15fd 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -366,26 +366,32 @@ export class Replayer { } const event = new Event(MouseInteractions[d.type].toLowerCase()); const target = (mirror.getNode(d.id) as Node) as HTMLElement; - if (d.type === MouseInteractions.Blur) { - target.blur(); - } else if (d.type === MouseInteractions.Click) { - /** - * Click has no visual impact when replaying and may - * trigger navigation when apply to an link. - * So we will not call click(), instead we add an - * animation to the mouse element which indicate user - * clicked at this moment. - */ - this.mouse.classList.remove('active'); - // tslint:disable-next-line - void this.mouse.offsetWidth; - this.mouse.classList.add('active'); - } else if (d.type === MouseInteractions.Focus) { - target.focus({ - preventScroll: true, - }); - } else { - target.dispatchEvent(event); + switch (d.type) { + case MouseInteractions.Blur: + target.blur(); + break; + case MouseInteractions.Focus: + target.focus({ + preventScroll: true, + }); + break; + case MouseInteractions.Click: + /** + * Click has no visual impact when replaying and may + * trigger navigation when apply to an link. + * So we will not call click(), instead we add an + * animation to the mouse element which indicate user + * clicked at this moment. + */ + if (!isSync) { + this.mouse.classList.remove('active'); + // tslint:disable-next-line + void this.mouse.offsetWidth; + this.mouse.classList.add('active'); + } + break; + default: + target.dispatchEvent(event); } break; }