From 9e43b0625a512095931add6f8e50e00b492459a4 Mon Sep 17 00:00:00 2001 From: midzelis Date: Mon, 25 Aug 2025 00:05:56 +0000 Subject: [PATCH] Minor scrubber refactor --- .../base-components/base-timeline.svelte | 25 ++++++++----------- web/src/lib/utils/timeline-util.ts | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/web/src/lib/components/timeline/base-components/base-timeline.svelte b/web/src/lib/components/timeline/base-components/base-timeline.svelte index 1f87fdfe05..b254b4a457 100644 --- a/web/src/lib/components/timeline/base-components/base-timeline.svelte +++ b/web/src/lib/components/timeline/base-components/base-timeline.svelte @@ -165,26 +165,23 @@ // note: don't throttle, debounce, or otherwise make this function async - it causes flicker // this function scrolls the timeline to the specified month group and offset, based on scrubber interaction - const onScrub: ScrubberListener = ({ - scrubberMonth, - overallScrollPercent, - scrubberMonthScrollPercent, - scrollToFunction, - }) => { + const onScrub: ScrubberListener = (scrubberData) => { + const { scrubberMonth, overallScrollPercent, scrubberMonthScrollPercent, scrollToFunction } = scrubberData; + if (!scrubberMonth || timelineManager.timelineHeight < timelineManager.viewportHeight * 2) { // edge case - scroll limited due to size of content, must adjust - use use the overall percent instead const maxScroll = timelineManager.getMaxScroll(); const offset = maxScroll * overallScrollPercent; scrollToFunction?.(offset); - } else { - const monthGroup = timelineManager.months.find( - ({ yearMonth: { year, month } }) => year === scrubberMonth.year && month === scrubberMonth.month, - ); - if (!monthGroup) { - return; - } - scrollToMonthGroupAndOffset(monthGroup, scrubberMonthScrollPercent, scrollToFunction); + return; } + const monthGroup = timelineManager.months.find( + ({ yearMonth: { year, month } }) => year === scrubberMonth.year && month === scrubberMonth.month, + ); + if (!monthGroup) { + return; + } + scrollToMonthGroupAndOffset(monthGroup, scrubberMonthScrollPercent, scrollToFunction); }; const scrollToMonthGroupAndOffset = ( diff --git a/web/src/lib/utils/timeline-util.ts b/web/src/lib/utils/timeline-util.ts index f32076de89..8d9ebbd257 100644 --- a/web/src/lib/utils/timeline-util.ts +++ b/web/src/lib/utils/timeline-util.ts @@ -23,7 +23,7 @@ export type TimelineDateTime = TimelineDate & { millisecond: number; }; -export type ScrubberListener = (args: { +export type ScrubberListener = (scrubberData: { scrubberMonth: { year: number; month: number }; overallScrollPercent: number; scrubberMonthScrollPercent: number;