From f55c593705bf7d0eb0ad0fc02c13bf1474bbfd91 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 24 Jun 2025 21:35:41 +1000 Subject: [PATCH] refactor: gallery scroll (improved impl) --- .../web/src/features/gallery/components/NewGallery.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/NewGallery.tsx b/invokeai/frontend/web/src/features/gallery/components/NewGallery.tsx index ebc5bc1615..b6fb9ed6ae 100644 --- a/invokeai/frontend/web/src/features/gallery/components/NewGallery.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/NewGallery.tsx @@ -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, };