From 168b067398b67fa4efdfb0372f6dfc5097ffac4f Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 8 Apr 2025 18:39:17 -0500 Subject: [PATCH] Moved timeline scrollbar to top. --- frontend/src/pages/Guide.jsx | 146 +++++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 51 deletions(-) diff --git a/frontend/src/pages/Guide.jsx b/frontend/src/pages/Guide.jsx index fd72d6a9..54fedb5a 100644 --- a/frontend/src/pages/Guide.jsx +++ b/frontend/src/pages/Guide.jsx @@ -58,6 +58,7 @@ export default function TVChannelGuide({ startDate, endDate }) { } = useSettingsStore(); const guideRef = useRef(null); + const timelineRef = useRef(null); // New ref for timeline scrolling // Load program data once useEffect(() => { @@ -185,13 +186,16 @@ export default function TVChannelGuide({ startDate, endDate }) { // Scroll to the nearest half-hour mark ONLY on initial load useEffect(() => { - if (guideRef.current && programs.length > 0 && !initialScrollComplete) { + if (guideRef.current && timelineRef.current && programs.length > 0 && !initialScrollComplete) { // Round the current time to the nearest half-hour mark const roundedNow = now.minute() < 30 ? now.startOf('hour') : now.startOf('hour').add(30, 'minute'); const nowOffset = roundedNow.diff(start, 'minute'); const scrollPosition = (nowOffset / MINUTE_INCREMENT) * MINUTE_BLOCK_WIDTH - MINUTE_BLOCK_WIDTH; - guideRef.current.scrollLeft = Math.max(scrollPosition, 0); + + const scrollPos = Math.max(scrollPosition, 0); + guideRef.current.scrollLeft = scrollPos; + timelineRef.current.scrollLeft = scrollPos; // Sync timeline scroll // Mark initial scroll as complete setInitialScrollComplete(true); @@ -275,14 +279,30 @@ export default function TVChannelGuide({ startDate, endDate }) { // Function to scroll to current time - matches initial loading position const scrollToNow = () => { - if (guideRef.current && nowPosition >= 0) { + if (guideRef.current && timelineRef.current && nowPosition >= 0) { // Round the current time to the nearest half-hour mark const roundedNow = now.minute() < 30 ? now.startOf('hour') : now.startOf('hour').add(30, 'minute'); const nowOffset = roundedNow.diff(start, 'minute'); const scrollPosition = (nowOffset / MINUTE_INCREMENT) * MINUTE_BLOCK_WIDTH - MINUTE_BLOCK_WIDTH; - guideRef.current.scrollLeft = Math.max(scrollPosition, 0); + const scrollPos = Math.max(scrollPosition, 0); + guideRef.current.scrollLeft = scrollPos; + timelineRef.current.scrollLeft = scrollPos; // Sync timeline scroll + } + }; + + // Sync scrolling between timeline and main content + const handleTimelineScroll = () => { + if (timelineRef.current && guideRef.current) { + guideRef.current.scrollLeft = timelineRef.current.scrollLeft; + } + }; + + // Sync scrolling between main content and timeline + const handleGuideScroll = () => { + if (guideRef.current && timelineRef.current) { + timelineRef.current.scrollLeft = guideRef.current.scrollLeft; } }; @@ -539,67 +559,54 @@ export default function TVChannelGuide({ startDate, endDate }) { {/* Guide container with headers and scrollable content */} - {/* Main scrollable container that will scroll both headers and content */} + {/* Logo header - Sticky, non-scrollable */} - {/* Content wrapper with min-width to ensure scroll range */} - - {/* Now line - positioned absolutely within content */} - {nowPosition >= 0 && ( - - )} + {/* Logo header cell - sticky in both directions */} + - {/* Fixed header row - sticky top, scrolls horizontally with content */} + {/* Timeline header with its own scrollbar */} + - {/* Logo header - sticky in both directions */} - - {/* Timeline header - scrolls horizontally with content */} - {hourTimeline.map((time, hourIndex) => ( @@ -651,6 +658,42 @@ export default function TVChannelGuide({ startDate, endDate }) { ))} + + + + {/* Main scrollable container for program content */} + + {/* Content wrapper with min-width to ensure scroll range */} + + {/* Now line - positioned absolutely within content */} + {nowPosition >= 0 && ( + + )} {/* Channel rows with logos and programs */} {filteredChannels.length > 0 ? ( @@ -683,6 +726,7 @@ export default function TVChannelGuide({ startDate, endDate }) { zIndex: 10, }} > + {/* Logo content - unchanged */}