mirror of
https://github.com/immich-app/immich.git
synced 2025-06-04 22:24:26 -04:00
fix(web): scrollbar year label visibility (#4820)
* fixes year label visibility * format fix
This commit is contained in:
parent
b58edae134
commit
92bb42950e
@ -21,11 +21,27 @@
|
|||||||
|
|
||||||
$: hoverY = height - windowHeight + clientY;
|
$: hoverY = height - windowHeight + clientY;
|
||||||
$: scrollY = toScrollY(timelineY);
|
$: scrollY = toScrollY(timelineY);
|
||||||
$: segments = $assetStore.buckets.map((bucket) => ({
|
|
||||||
|
class Segment {
|
||||||
|
public count;
|
||||||
|
public height;
|
||||||
|
public timeGroup;
|
||||||
|
|
||||||
|
constructor({ count = 0, height = 0, timeGroup = '' }) {
|
||||||
|
this.count = count;
|
||||||
|
this.height = height;
|
||||||
|
this.timeGroup = timeGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: segments = $assetStore.buckets.map(
|
||||||
|
(bucket) =>
|
||||||
|
new Segment({
|
||||||
count: bucket.assets.length,
|
count: bucket.assets.length,
|
||||||
height: toScrollY(bucket.bucketHeight),
|
height: toScrollY(bucket.bucketHeight),
|
||||||
timeGroup: bucket.bucketDate,
|
timeGroup: bucket.bucketDate,
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{ scrollTimeline: number }>();
|
const dispatch = createEventDispatcher<{ scrollTimeline: number }>();
|
||||||
const scrollTimeline = () => dispatch('scrollTimeline', toTimelineY(hoverY));
|
const scrollTimeline = () => dispatch('scrollTimeline', toTimelineY(hoverY));
|
||||||
@ -51,6 +67,23 @@
|
|||||||
isAnimating = false;
|
isAnimating = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const prevYearSegmentHeight = (segments: Segment[], index: number) => {
|
||||||
|
var prevYear = null;
|
||||||
|
var height = 0;
|
||||||
|
for (var i = index; i >= 0; i--) {
|
||||||
|
const curr = segments[i];
|
||||||
|
const currYear = fromLocalDateTime(curr.timeGroup).year;
|
||||||
|
if (prevYear && prevYear != currYear) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
height += curr.height;
|
||||||
|
prevYear = currYear;
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window bind:innerHeight={windowHeight} />
|
<svelte:window bind:innerHeight={windowHeight} />
|
||||||
@ -98,18 +131,6 @@
|
|||||||
{@const label = `${date.toLocaleString({ month: 'short' })} ${year}`}
|
{@const label = `${date.toLocaleString({ month: 'short' })} ${year}`}
|
||||||
{@const lastGroupYear = fromLocalDateTime(segments[index - 1]?.timeGroup).year}
|
{@const lastGroupYear = fromLocalDateTime(segments[index - 1]?.timeGroup).year}
|
||||||
|
|
||||||
<!-- Check if the next three segments are different years then don't render
|
|
||||||
to avoid overlapse -->
|
|
||||||
{@const canRenderYear = segments.slice(index + 1, index + 3).reduce((_, curr) => {
|
|
||||||
const nextGroupYear = fromLocalDateTime(curr.timeGroup).year;
|
|
||||||
|
|
||||||
if (nextGroupYear !== year || curr.height < 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}, true)}
|
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<div
|
<div
|
||||||
id="time-segment"
|
id="time-segment"
|
||||||
@ -118,7 +139,7 @@
|
|||||||
aria-label={segment.timeGroup + ' ' + segment.count}
|
aria-label={segment.timeGroup + ' ' + segment.count}
|
||||||
on:mousemove={() => (hoverLabel = label)}
|
on:mousemove={() => (hoverLabel = label)}
|
||||||
>
|
>
|
||||||
{#if lastGroupYear !== year && canRenderYear}
|
{#if lastGroupYear !== year && (index == 0 || prevYearSegmentHeight(segments, index - 1) > 16)}
|
||||||
<div
|
<div
|
||||||
aria-label={segment.timeGroup + ' ' + segment.count}
|
aria-label={segment.timeGroup + ' ' + segment.count}
|
||||||
class="absolute right-0 z-10 pr-5 text-xs font-medium dark:text-immich-dark-fg font-mono"
|
class="absolute right-0 z-10 pr-5 text-xs font-medium dark:text-immich-dark-fg font-mono"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user