diff --git a/web/src/lib/components/shared-components/gallery-viewer/gallery-viewer.svelte b/web/src/lib/components/shared-components/gallery-viewer/gallery-viewer.svelte index 30e14abc59..fad053fc67 100644 --- a/web/src/lib/components/shared-components/gallery-viewer/gallery-viewer.svelte +++ b/web/src/lib/components/shared-components/gallery-viewer/gallery-viewer.svelte @@ -145,12 +145,13 @@ let lastIntersectedHeight = 0; $effect(() => { - // notify we got to (near) the end of scroll - const scrollPercentage = - ((slidingWindow.bottom - viewport.height) / (viewport.height - (document.scrollingElement?.clientHeight || 0))) * - 100; + const scrollRatio = slidingWindow.bottom / assetLayouts.containerHeight; - if (scrollPercentage > 90) { + // TODO: We may want to limit to an absolute value as the ratio scaling will + // get weird with lots of assets. The page may be nowhere near the bottom in + // absolute terms, and yet the intersection will still be triggered. + if (scrollRatio > 0.9) { + // Notify we got to (near) the end of scroll. const intersectedHeight = geometry?.containerHeight || 0; if (lastIntersectedHeight !== intersectedHeight) { debouncedOnIntersected(); diff --git a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte index b3177fc39e..56e58c3633 100644 --- a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte +++ b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.svelte @@ -360,7 +360,7 @@ {/if}