From 6e2669e1cb9c1be3dc8444ae9427c4ec9c0918ba Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Mon, 17 Oct 2022 16:26:52 +0200 Subject: [PATCH] Fix: scrolling on elements being is ignored In certain cases when scrollLeft is being set, but the value doesn't change. Then scrollTop is also ignored, even if that value was changed. In this case we use the `scrollTo` api as it doesn't have that issue. --- packages/rrweb/src/replay/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/rrweb/src/replay/index.ts b/packages/rrweb/src/replay/index.ts index 6226211ed4..8d1db68123 100644 --- a/packages/rrweb/src/replay/index.ts +++ b/packages/rrweb/src/replay/index.ts @@ -1758,8 +1758,11 @@ export class Replayer { }); } else { try { - (target as Element).scrollTop = d.y; - (target as Element).scrollLeft = d.x; + (target as Element).scrollTo({ + top: d.y, + left: d.x, + behavior: isSync ? 'auto' : 'smooth', + }); } catch (error) { /** * Seldomly we may found scroll target was removed before