|
@@ -21,11 +21,27 @@
|
|
|
|
|
|
$: hoverY = height - windowHeight + clientY;
|
|
|
$: scrollY = toScrollY(timelineY);
|
|
|
- $: segments = $assetStore.buckets.map((bucket) => ({
|
|
|
- count: bucket.assets.length,
|
|
|
- height: toScrollY(bucket.bucketHeight),
|
|
|
- timeGroup: bucket.bucketDate,
|
|
|
- }));
|
|
|
+
|
|
|
+ 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,
|
|
|
+ height: toScrollY(bucket.bucketHeight),
|
|
|
+ timeGroup: bucket.bucketDate,
|
|
|
+ }),
|
|
|
+ );
|
|
|
|
|
|
const dispatch = createEventDispatcher<{ scrollTimeline: number }>();
|
|
|
const scrollTimeline = () => dispatch('scrollTimeline', toTimelineY(hoverY));
|
|
@@ -51,6 +67,23 @@
|
|
|
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>
|
|
|
|
|
|
<svelte:window bind:innerHeight={windowHeight} />
|
|
@@ -98,18 +131,6 @@
|
|
|
{@const label = `${date.toLocaleString({ month: 'short' })} ${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 -->
|
|
|
<div
|
|
|
id="time-segment"
|
|
@@ -118,7 +139,7 @@
|
|
|
aria-label={segment.timeGroup + ' ' + segment.count}
|
|
|
on:mousemove={() => (hoverLabel = label)}
|
|
|
>
|
|
|
- {#if lastGroupYear !== year && canRenderYear}
|
|
|
+ {#if lastGroupYear !== year && (index == 0 || prevYearSegmentHeight(segments, index - 1) > 16)}
|
|
|
<div
|
|
|
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"
|