Skip to content

High performance self-hosted photo and video management solution.

feat(web): don't scroll to visible assets (#20729)

Thomas1193a23282a2
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;