Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions web/src/lib/components/photos-page/asset-grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down