From 1193a23282a2ad3f733d12e5e15e2a130a8af320 Mon Sep 17 00:00:00 2001 From: Thomas <9749173+uhthomas@users.noreply.github.com> Date: Wed, 6 Aug 2025 22:31:37 +0100 Subject: [PATCH] feat(web): don't scroll to visible assets (#20729) The timeline has been quite aggressive with scrolling to assets, even if they were right in the middle of the page. If the asset is visible, then we shouldn't scroll to it. It's really confusing when assets jump around after being viewed. --- .../lib/components/photos-page/asset-grid.svelte | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web/src/lib/components/photos-page/asset-grid.svelte b/web/src/lib/components/photos-page/asset-grid.svelte index 808a4cf54c..69faf8e1e5 100644 --- a/web/src/lib/components/photos-page/asset-grid.svelte +++ b/web/src/lib/components/photos-page/asset-grid.svelte @@ -149,12 +149,28 @@ return height; }; + const assetIsVisible = (assetTop: number): boolean => { + if (!element) { + return false; + } + + const { clientHeight, scrollTop } = element; + return assetTop >= scrollTop && assetTop < scrollTop + clientHeight; + }; + const scrollToAssetId = async (assetId: string) => { const monthGroup = await timelineManager.findMonthGroupForAsset(assetId); if (!monthGroup) { return false; } + const height = getAssetHeight(assetId, monthGroup); + + // If the asset is already visible, then don't scroll. + if (assetIsVisible(height)) { + return true; + } + scrollTo(height); updateSlidingWindow(); return true;