snap bounds in virtual list

This commit is contained in:
Roland Osborne 2022-08-30 01:05:12 -07:00
parent 296bed18d5
commit 1254e8f4d8

View File

@ -109,16 +109,16 @@ export function VirtualList({ id, items, itemRenderer, loadMore }) {
const range = getContainerRange();
if (range.bottom - range.top < state.listHeight) {
if (scrollTop.current + state.listHeight != range.bottom) {
list.current.scrollTo({ top: range.bottom - state.listHeight, left: 0, behavior: 'smooth' });
list.current.scrollTo({ top: range.bottom - state.listHeight, left: 0 });
actions.latch();
}
}
else if (scrollTop.current + state.listHeight > range.bottom) {
list.current.scrollTo({ top: range.bottom - state.listHeight, left: 0, behavior: 'smooth' });
list.current.scrollTo({ top: range.bottom - state.listHeight, left: 0 });
actions.latch();
}
else if (scrollTop.current < range.top) {
list.current.scrollTo({ top: range.top, left: 0, behavior: 'smooth' });
list.current.scrollTo({ top: range.top, left: 0 });
}
}
}, pushDelay);