Now that the fix for that issue is released, I'm no longer experiencing the center date issue. However, I'm running into a separate issue.
My use case
I have the scheduler configured with a axis of 2019-Apr-01 to 2019-Jul-01. I'm setting zoom levels of 1 day, 3 day, 7 day, 30 day.
I have zoom levels with arbitrary dates that match those ranges:
{
1: {
startDate: new Date("2019-04-01T00:00:00-0400"),
endDate: new Date("2019-04-02T00:00:00-0400")
},
3: {
startDate: new Date("2019-04-01T00:00:00-0400"),
endDate: new Date("2019-04-04T00:00:00-0400")
},
7: {
startDate: new Date("2019-04-01T00:00:00-0400"),
endDate: new Date("2019-04-09T00:00:00-0400")
},
30: {
startDate: new Date("2019-04-01T00:00:00-0400"),
endDate: new Date("2019-05-01T00:00:00-0400")
}
}
const centerDate = this.scheduler.schedulerEngine.viewportCenterDate || new Date();
this.scheduler.schedulerEngine.zoomTo({ ...ZOOM_LEVEL_MAPPINGS[zoomLevel], centerDate });
I expect selecting the zoom level to:
- Keep the view centered on the currently centered date
- Change the zoom level so that the specified number of days (1, 3, 7, 30) is visible in the view exactly.
- Maintain the start and end date of Apr 1 and Jul 1 for the overall view, so that the user can scroll left and right to those dates if they choose, after zooming.
Expectations 1 and 2 from above are met. Expectation 3 is not met. The start and end dates (ie., limits of scrolling) change to unpredictable values.
It seems that after it zooms to the span, it calls 'calculateOptimalDateRange'. That function has an argument userProvidedSpan to prevent setting its own range, but this is not used in this codepath.
Questions
- Is this expected behaviour? That zooming to a span will result in unpredictable start and end dates being applied? Or is this a defect?
- If it's expected, any other thoughts on how I can achieve my desired behaviour?