refactor: gallery scroll (improved impl)

This commit is contained in:
psychedelicious
2025-06-24 21:35:41 +10:00
parent 8327d86774
commit f55c593705

View File

@@ -41,6 +41,8 @@ type ImageCollectionQueryArgs = {
// Constants
const RANGE_SIZE = 50;
const VIEWPORT_BUFFER = 2048;
const SCROLL_SEEK_VELOCITY_THRESHOLD = 2048;
type GridContext = {
queryArgs: ImageCollectionQueryArgs;
@@ -283,7 +285,7 @@ export const NewGallery = memo(() => {
context={context}
totalCount={imageNames.length}
data={imageNames}
increaseViewportBy={2048}
increaseViewportBy={VIEWPORT_BUFFER}
itemContent={itemContent}
computeItemKey={computeItemKey}
components={components}
@@ -299,7 +301,7 @@ export const NewGallery = memo(() => {
NewGallery.displayName = 'NewGallery';
const scrollSeekConfiguration: ScrollSeekConfiguration = {
enter: (velocity) => velocity > 2048,
enter: (velocity) => velocity > SCROLL_SEEK_VELOCITY_THRESHOLD,
exit: (velocity) => velocity === 0,
};