Skip to content

Commit 1193a23

Browse files
authored
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.
1 parent bbfff64 commit 1193a23

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

web/src/lib/components/photos-page/asset-grid.svelte

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,28 @@
149149
return height;
150150
};
151151
152+
const assetIsVisible = (assetTop: number): boolean => {
153+
if (!element) {
154+
return false;
155+
}
156+
157+
const { clientHeight, scrollTop } = element;
158+
return assetTop >= scrollTop && assetTop < scrollTop + clientHeight;
159+
};
160+
152161
const scrollToAssetId = async (assetId: string) => {
153162
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
154163
if (!monthGroup) {
155164
return false;
156165
}
166+
157167
const height = getAssetHeight(assetId, monthGroup);
168+
169+
// If the asset is already visible, then don't scroll.
170+
if (assetIsVisible(height)) {
171+
return true;
172+
}
173+
158174
scrollTo(height);
159175
updateSlidingWindow();
160176
return true;

0 commit comments

Comments
 (0)