I have a custom component above the Daypilot Scheduler that shows current visible start date and visible end date of the Daypilot scheduler for the current zoom level (Quarter as per screenshot).
I am currently getting the visible dates via a native onscroll listener.
useEffect(() => {
const el = scheduler?.nav?.scroll;
if (!el || !myScheduler) return;
const onScroll = () => {
const viewport = myScheduler.getViewport();
const visibleWindowStartDate = viewport.start;
const visibleWindowEndDate = viewport.end;
// updateVisibleDates(visibleWindowStartDate, visibleWindowEndDate)
});
};
el.addEventListener("scroll", onScroll, { passive: true });
return () => el.removeEventListener("scroll", onScroll);
}, [myScheduler, syncWithLatestViewport]);
Below is relevant Daypilot scheduler props.
zoom={currentZoom}
zoomPosition='middle'
zoomLevel={[{
id: ‘quarter’,
properties: {
"scale": "Week",
"timeHeaders": [
{
"groupBy": "Month",
"format": "MMM"
},
{
"groupBy": "Week"
}
],
days: 720,
"cellWidthSpec": "Fixed",
"cellWidth": 130,
"infiniteScrollingEnabled": true,
"infiniteScrollingMargin": 30,
"infiniteScrollingStepDays": 365
}}]}
Problem: On smaller screen, because the timeline’s window is smaller, the visible dates can sometimes show `Jan - Feb`, which is only 1 month, instead of 3 months range expected of quarter view. Same issue on very wide screen (ie: showing a visible range as big as 6 months, Jan - Jul).
Question: What is the best practical approach to keep the visible dates consistent, regardless of user’s window size? In the above example, the visible window should always show 3 months range when scrolling, on any screen size.
Considered approaches: I looked into `cellWidthSpec: Auto` which seems to achieve the desired behaviour, but doesn’t work well with infinite scrolling. My first instinct is to find a hacky way to “responsively” calculate `cellWidth`.