From 13b8a69213897836368cf7136685ab20b26d84e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B8=A9=E5=9D=91=E5=B0=8F=E7=8E=8B=E5=AD=90?= <294889365@qq.com> Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] feat: enable to change the config of mouse tail while playing (#410) fix a potential bug: handleResize function might change the display style of mouseTail --- src/replay/index.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index ab7a3537..b18c548f 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -220,6 +220,20 @@ export class Replayer { }, }); } + if (typeof config.mouseTail !== 'undefined') { + if (config.mouseTail === false) { + this.mouseTail && (this.mouseTail.style.display = 'none'); + } else { + if (!this.mouseTail) { + this.mouseTail = document.createElement('canvas'); + this.mouseTail.width = Number.parseFloat(this.iframe.width); + this.mouseTail.height = Number.parseFloat(this.iframe.height); + this.mouseTail.classList.add('replayer-mouse-tail'); + this.wrapper.insertBefore(this.mouseTail, this.iframe); + } + this.mouseTail.style.display = 'inherit'; + } + } } public getMetaData(): playerMetaData { @@ -316,7 +330,7 @@ export class Replayer { if (this.config.mouseTail !== false) { this.mouseTail = document.createElement('canvas'); this.mouseTail.classList.add('replayer-mouse-tail'); - this.mouseTail.style.display = 'none'; + this.mouseTail.style.display = 'inherit'; this.wrapper.appendChild(this.mouseTail); } @@ -341,11 +355,11 @@ export class Replayer { } private handleResize(dimension: viewportResizeDimention) { + this.iframe.style.display = 'inherit'; for (const el of [this.mouseTail, this.iframe]) { if (!el) { continue; } - el.style.display = 'inherit'; el.setAttribute('width', String(dimension.width)); el.setAttribute('height', String(dimension.height)); }