From 39f3e4d4db845698b43d946c9d1d1fcdd8b96484 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Sun, 7 Apr 2024 10:12:38 +0800 Subject: [PATCH 1/6] fix: solve the smooth scrolling scene, the y value obtained is the data 100ms ago --- packages/rrweb/src/record/observer.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/rrweb/src/record/observer.ts b/packages/rrweb/src/record/observer.ts index 0aa0f9856b..ee7c0e33d0 100644 --- a/packages/rrweb/src/record/observer.ts +++ b/packages/rrweb/src/record/observer.ts @@ -375,6 +375,9 @@ export function initScrollObserver({ } }), sampling.scroll || 100, + { + trailing: true + } ), ); return on('scroll', updatePosition, doc); From 67c8d389bc3a2a9946047916f853a0eefdb54f36 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Sun, 7 Apr 2024 16:27:49 +0800 Subject: [PATCH 2/6] fix: solve the smooth scrolling scene, the y value obtained is the data 100ms ago --- packages/rrweb/src/record/observer.ts | 5 +---- packages/rrweb/src/utils.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/rrweb/src/record/observer.ts b/packages/rrweb/src/record/observer.ts index ee7c0e33d0..42c3020c47 100644 --- a/packages/rrweb/src/record/observer.ts +++ b/packages/rrweb/src/record/observer.ts @@ -374,10 +374,7 @@ export function initScrollObserver({ }); } }), - sampling.scroll || 100, - { - trailing: true - } + sampling.scroll || 100 ), ); return on('scroll', updatePosition, doc); diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index f426689d2f..f2e423c0d1 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -88,10 +88,19 @@ export function throttle( previous = now; func.apply(context, args); } else if (!timeout && options.trailing !== false) { + const argumentsList = args.map((arg: Omit) => { + return { + ...arg, + target: arg.target || null + } + }) timeout = setTimeout(() => { previous = options.leading === false ? 0 : Date.now(); - timeout = null; - func.apply(context, args); + if (timeout) { + clearTimeout(timeout) + timeout = null; + } + func.apply(context, argumentsList); }, remaining); } }; From 0e0c03028db13d54e330ec7d474821ef5f777b17 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Sun, 7 Apr 2024 16:29:22 +0800 Subject: [PATCH 3/6] fix: solve the smooth scrolling scene, the y value obtained is the data 100ms ago --- packages/rrweb/src/record/observer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rrweb/src/record/observer.ts b/packages/rrweb/src/record/observer.ts index 42c3020c47..0aa0f9856b 100644 --- a/packages/rrweb/src/record/observer.ts +++ b/packages/rrweb/src/record/observer.ts @@ -374,7 +374,7 @@ export function initScrollObserver({ }); } }), - sampling.scroll || 100 + sampling.scroll || 100, ), ); return on('scroll', updatePosition, doc); From 1d3897853d6f3f1f4c0a0c990d41440089b60b10 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Sun, 7 Apr 2024 16:38:54 +0800 Subject: [PATCH 4/6] fix: solve the smooth scrolling scene, the y value obtained is the data 100ms ago --- packages/rrweb/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index f2e423c0d1..04c7e62af6 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -88,7 +88,7 @@ export function throttle( previous = now; func.apply(context, args); } else if (!timeout && options.trailing !== false) { - const argumentsList = args.map((arg: Omit) => { + const argumentsList = args.map((arg: T)=> { return { ...arg, target: arg.target || null From af4073e0725a02fc1ff34128e9a4ab182c227997 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Sun, 7 Apr 2024 16:39:40 +0800 Subject: [PATCH 5/6] fix: solve the smooth scrolling scene, the y value obtained is the data 100ms ago --- packages/rrweb/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index 04c7e62af6..9e4c754562 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -91,7 +91,7 @@ export function throttle( const argumentsList = args.map((arg: T)=> { return { ...arg, - target: arg.target || null + target: arg.target } }) timeout = setTimeout(() => { From c04104dadb0911c1bf99a844d242839a71a25c97 Mon Sep 17 00:00:00 2001 From: xujiujiu <906784584@qq.com> Date: Thu, 11 Apr 2024 11:02:58 +0800 Subject: [PATCH 6/6] fix: scroll event throttle save target path --- packages/rrweb/src/utils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/rrweb/src/utils.ts b/packages/rrweb/src/utils.ts index 9e4c754562..359153e12d 100644 --- a/packages/rrweb/src/utils.ts +++ b/packages/rrweb/src/utils.ts @@ -89,15 +89,15 @@ export function throttle( func.apply(context, args); } else if (!timeout && options.trailing !== false) { const argumentsList = args.map((arg: T)=> { - return { - ...arg, - target: arg.target + const argTmp = {...arg} + if (arg.target) { + argTmp.target = arg.target } + return argTmp }) timeout = setTimeout(() => { previous = options.leading === false ? 0 : Date.now(); if (timeout) { - clearTimeout(timeout) timeout = null; } func.apply(context, argumentsList);