feat(timeline): start at today + infinite scroll into the past #65
@@ -698,16 +698,16 @@ function TimelineViewContent({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Scroll to today the first time the canvas has its full width (after initial data load).
|
// Scroll to today the first time the canvas is in the DOM (isInitialLoading → false).
|
||||||
// Depends on totalCanvasWidth so it fires after isInitialLoading → false renders the canvas.
|
// totalCanvasWidth is non-zero before data loads, so it can't be used as the trigger.
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (totalCanvasWidth === 0) return;
|
if (isInitialLoading) return;
|
||||||
if (hasScrolledToTodayOnLoad.current) return;
|
if (hasScrolledToTodayOnLoad.current) return;
|
||||||
const el = scrollContainerRef.current;
|
const el = scrollContainerRef.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
el.scrollLeft = toLeft(today);
|
el.scrollLeft = toLeft(today);
|
||||||
hasScrolledToTodayOnLoad.current = true;
|
hasScrolledToTodayOnLoad.current = true;
|
||||||
}, [totalCanvasWidth, toLeft, today]);
|
}, [isInitialLoading, toLeft, today]);
|
||||||
|
|
||||||
// Apply scroll compensation synchronously after the canvas grows (left-extend or Today button).
|
// Apply scroll compensation synchronously after the canvas grows (left-extend or Today button).
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user