From 4c0e9dfe82c8591e6a183a23cd3c5e56da88ae9e Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Fri, 30 Apr 2021 12:15:04 +1000 Subject: [PATCH] VirtualScroller: fix pendings and scroll after jump --- .../src/views/components/VirtualScroller.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pkg/interface/src/views/components/VirtualScroller.tsx b/pkg/interface/src/views/components/VirtualScroller.tsx index e366ef2b8c..cadb6f0b2b 100644 --- a/pkg/interface/src/views/components/VirtualScroller.tsx +++ b/pkg/interface/src/views/components/VirtualScroller.tsx @@ -93,7 +93,7 @@ const log = (level: LogLevel, message: string) => { } } -const ZONE_SIZE = IS_IOS ? 10 : 80; +const ZONE_SIZE = IS_IOS ? 20 : 80; // nb: in this file, an index refers to a BigInteger and an offset refers to a @@ -208,7 +208,8 @@ export default class VirtualScroller extends Component extends Component { ref = this.childRefs.get(index.toString()); - this.savedIndex = null; - this.savedDistance = 0; - this.saveDepth = 0; + requestAnimationFrame(() => { + this.savedIndex = null; + this.savedDistance = 0; + this.saveDepth = 0; + }); ref?.scrollIntoView({ block: 'center' }); }); } else { - this.savedIndex = null; - this.savedDistance = 0; - this.saveDepth = 0; - ref?.scrollIntoView({ block: 'center' }); + requestAnimationFrame(() => { + this.savedIndex = null; + this.savedDistance = 0; + this.saveDepth = 0; + }); + } };