feat(timeline): start at today + infinite scroll into the past #65
@@ -689,17 +689,15 @@ function TimelineViewContent({
|
|||||||
const pendingLeftCompensationPx = useRef(0);
|
const pendingLeftCompensationPx = useRef(0);
|
||||||
// Flag: scroll viewport to today after the next viewStart-driven re-layout.
|
// Flag: scroll viewport to today after the next viewStart-driven re-layout.
|
||||||
const pendingScrollToTodayRef = useRef(false);
|
const pendingScrollToTodayRef = useRef(false);
|
||||||
// Guard: only auto-scroll to today once on initial mount.
|
|
||||||
const scrolledToTodayOnMount = useRef(false);
|
|
||||||
|
|
||||||
// Scroll to today on first mount so the viewport opens with today at the left edge.
|
// Scroll to today on mount so the viewport opens with today at the left edge.
|
||||||
|
// Empty deps: intentionally runs once (and twice in React Strict Mode dev, both correct).
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (scrolledToTodayOnMount.current) return;
|
|
||||||
const el = scrollContainerRef.current;
|
const el = scrollContainerRef.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
el.scrollLeft = toLeft(today);
|
el.scrollLeft = toLeft(today);
|
||||||
scrolledToTodayOnMount.current = true;
|
}, []);
|
||||||
}, [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