mirror of
https://github.com/urbit/shrub.git
synced 2024-12-11 11:02:25 +03:00
VirtualScroller: fix pendings and scroll after jump
This commit is contained in:
parent
93c6d157af
commit
4c0e9dfe82
@ -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<T> extends Component<VirtualScrollerProps<T
|
||||
const { id, size, data, offset, pendingSize } = this.props;
|
||||
|
||||
if(size !== prevProps.size || pendingSize !== prevProps.pendingSize) {
|
||||
if(this.scrollLocked) {
|
||||
if((this.window?.scrollTop ?? 0) < ZONE_SIZE) {
|
||||
this.scrollLocked = true;
|
||||
this.updateVisible(0);
|
||||
this.resetScroll();
|
||||
}
|
||||
@ -449,21 +450,26 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
|
||||
if(offset === -1) {
|
||||
return;
|
||||
}
|
||||
this.scrollLocked = false;
|
||||
this.updateVisible(Math.max(offset - this.pageDelta, 0));
|
||||
requestAnimationFrame(() => {
|
||||
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;
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user