mirror of
https://github.com/immich-app/immich.git
synced 2025-08-11 09:16:31 -04:00
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.
This commit is contained in:
parent
bbfff64927
commit
1193a23282
@ -149,12 +149,28 @@
|
|||||||
return height;
|
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 scrollToAssetId = async (assetId: string) => {
|
||||||
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
|
const monthGroup = await timelineManager.findMonthGroupForAsset(assetId);
|
||||||
if (!monthGroup) {
|
if (!monthGroup) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const height = getAssetHeight(assetId, monthGroup);
|
const height = getAssetHeight(assetId, monthGroup);
|
||||||
|
|
||||||
|
// If the asset is already visible, then don't scroll.
|
||||||
|
if (assetIsVisible(height)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
scrollTo(height);
|
scrollTo(height);
|
||||||
updateSlidingWindow();
|
updateSlidingWindow();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user