Minor scrubber refactor
This commit is contained in:
@@ -165,18 +165,16 @@
|
|||||||
|
|
||||||
// note: don't throttle, debounce, or otherwise make this function async - it causes flicker
|
// 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
|
// this function scrolls the timeline to the specified month group and offset, based on scrubber interaction
|
||||||
const onScrub: ScrubberListener = ({
|
const onScrub: ScrubberListener = (scrubberData) => {
|
||||||
scrubberMonth,
|
const { scrubberMonth, overallScrollPercent, scrubberMonthScrollPercent, scrollToFunction } = scrubberData;
|
||||||
overallScrollPercent,
|
|
||||||
scrubberMonthScrollPercent,
|
|
||||||
scrollToFunction,
|
|
||||||
}) => {
|
|
||||||
if (!scrubberMonth || timelineManager.timelineHeight < timelineManager.viewportHeight * 2) {
|
if (!scrubberMonth || timelineManager.timelineHeight < timelineManager.viewportHeight * 2) {
|
||||||
// edge case - scroll limited due to size of content, must adjust - use use the overall percent instead
|
// edge case - scroll limited due to size of content, must adjust - use use the overall percent instead
|
||||||
const maxScroll = timelineManager.getMaxScroll();
|
const maxScroll = timelineManager.getMaxScroll();
|
||||||
const offset = maxScroll * overallScrollPercent;
|
const offset = maxScroll * overallScrollPercent;
|
||||||
scrollToFunction?.(offset);
|
scrollToFunction?.(offset);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
const monthGroup = timelineManager.months.find(
|
const monthGroup = timelineManager.months.find(
|
||||||
({ yearMonth: { year, month } }) => year === scrubberMonth.year && month === scrubberMonth.month,
|
({ yearMonth: { year, month } }) => year === scrubberMonth.year && month === scrubberMonth.month,
|
||||||
);
|
);
|
||||||
@@ -184,7 +182,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scrollToMonthGroupAndOffset(monthGroup, scrubberMonthScrollPercent, scrollToFunction);
|
scrollToMonthGroupAndOffset(monthGroup, scrubberMonthScrollPercent, scrollToFunction);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const scrollToMonthGroupAndOffset = (
|
const scrollToMonthGroupAndOffset = (
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export type TimelineDateTime = TimelineDate & {
|
|||||||
millisecond: number;
|
millisecond: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ScrubberListener = (args: {
|
export type ScrubberListener = (scrubberData: {
|
||||||
scrubberMonth: { year: number; month: number };
|
scrubberMonth: { year: number; month: number };
|
||||||
overallScrollPercent: number;
|
overallScrollPercent: number;
|
||||||
scrubberMonthScrollPercent: number;
|
scrubberMonthScrollPercent: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user