mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
feat(web) add scrollbar with timeline information (#658)
- Implement a scrollbar with a timeline similar to Google Photos - The scrollbar can also be dragged
This commit is contained in:
@@ -34,7 +34,7 @@ function createAssetStore() {
|
||||
assetGridState.set({
|
||||
viewportHeight,
|
||||
viewportWidth,
|
||||
timelineHeight: calculateViewportHeightByNumberOfAsset(data.totalCount, viewportWidth),
|
||||
timelineHeight: 0,
|
||||
buckets: data.buckets.map((d) => ({
|
||||
bucketDate: d.timeBucket,
|
||||
bucketHeight: calculateViewportHeightByNumberOfAsset(d.count, viewportWidth),
|
||||
@@ -43,6 +43,12 @@ function createAssetStore() {
|
||||
})),
|
||||
assets: []
|
||||
});
|
||||
|
||||
// Update timeline height based on calculated bucket height
|
||||
assetGridState.update((state) => {
|
||||
state.timelineHeight = lodash.sumBy(state.buckets, (d) => d.bucketHeight);
|
||||
return state;
|
||||
});
|
||||
};
|
||||
|
||||
const getAssetsByBucket = async (bucket: string) => {
|
||||
@@ -108,10 +114,19 @@ function createAssetStore() {
|
||||
});
|
||||
};
|
||||
|
||||
const updateBucketHeight = (bucket: string, height: number) => {
|
||||
const updateBucketHeight = (bucket: string, actualBucketHeight: number) => {
|
||||
assetGridState.update((state) => {
|
||||
const bucketIndex = state.buckets.findIndex((b) => b.bucketDate === bucket);
|
||||
state.buckets[bucketIndex].bucketHeight = height;
|
||||
// Update timeline height based on the new bucket height
|
||||
const estimateBucketHeight = state.buckets[bucketIndex].bucketHeight;
|
||||
|
||||
if (actualBucketHeight >= estimateBucketHeight) {
|
||||
state.timelineHeight += actualBucketHeight - estimateBucketHeight;
|
||||
} else {
|
||||
state.timelineHeight -= estimateBucketHeight - actualBucketHeight;
|
||||
}
|
||||
|
||||
state.buckets[bucketIndex].bucketHeight = actualBucketHeight;
|
||||
return state;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user