disable smooth scroll behavior in sync mode (#824)

This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 36c746756e
commit 2bca850543

View File

@@ -183,7 +183,7 @@ export class Replayer {
this.virtualStyleRulesMap.clear(); this.virtualStyleRulesMap.clear();
for (const d of scrollMap.values()) { for (const d of scrollMap.values()) {
this.applyScroll(d); this.applyScroll(d, true);
} }
for (const d of inputMap.values()) { for (const d of inputMap.values()) {
this.applyInput(d); this.applyInput(d);
@@ -985,7 +985,7 @@ export class Replayer {
this.treeIndex.scroll(d); this.treeIndex.scroll(d);
break; break;
} }
this.applyScroll(d); this.applyScroll(d, false);
break; break;
} }
case IncrementalSource.ViewportResize: case IncrementalSource.ViewportResize:
@@ -1598,7 +1598,13 @@ export class Replayer {
}); });
} }
private applyScroll(d: scrollData) { /**
* Apply the scroll data on real elements.
* If the replayer is in sync mode, smooth scroll behavior should be disabled.
* @param d the scroll data
* @param isSync whether the replayer is in sync mode(fast-forward)
*/
private applyScroll(d: scrollData, isSync: boolean) {
const target = this.mirror.getNode(d.id); const target = this.mirror.getNode(d.id);
if (!target) { if (!target) {
return this.debugNodeNotFound(d, d.id); return this.debugNodeNotFound(d, d.id);
@@ -1607,14 +1613,14 @@ export class Replayer {
this.iframe.contentWindow!.scrollTo({ this.iframe.contentWindow!.scrollTo({
top: d.y, top: d.y,
left: d.x, left: d.x,
behavior: 'smooth', behavior: isSync ? 'auto' : 'smooth',
}); });
} else if (target.__sn.type === NodeType.Document) { } else if (target.__sn.type === NodeType.Document) {
// nest iframe content document // nest iframe content document
((target as unknown) as Document).defaultView!.scrollTo({ ((target as unknown) as Document).defaultView!.scrollTo({
top: d.y, top: d.y,
left: d.x, left: d.x,
behavior: 'smooth', behavior: isSync ? 'auto' : 'smooth',
}); });
} else { } else {
try { try {