React-calendar-timeline: Limit Days

Created on 10 Nov 2017  路  4Comments  路  Source: namespace-ee/react-calendar-timeline

How can I limit the calendar to yesterday, today and tomorrow?

thanks

Most helpful comment

To build on what @Biohazord said, heres a working example that limits the range from yesterday to tomorrow:

https://codesandbox.io/s/m31jpjn9oy

It's a little buggy on scroll but gives an idea of how to accomplish this.

All 4 comments

I had a similar situation. I wanted to display just a slice of a single day and then manually control navigation between days. To do this I used the Timeline components visibleStartTime, visibielEndTime, and onTimeChange props.

For your case you'll probably need to use those props as well as the onBoundsChange, canvasTimeStart, and canvasTimeEnd prop in a similar way.

In my use case I defined dayStart and dayEnd variables which are JavaScript Dates. I then used it as follows with the props.

visibleTimeStart={dayStart}
visibleTimeEnd={dayEnd}
// Prevents the time from changing beyond our selected date.
onTimeChange={(visibleTimeStart, visibleTimeEnd, updateScrollCanvas) => updateScrollCanvas(dayStart, dayEnd)}

To build on what @Biohazord said, heres a working example that limits the range from yesterday to tomorrow:

https://codesandbox.io/s/m31jpjn9oy

It's a little buggy on scroll but gives an idea of how to accomplish this.

@mcMickJuice @Biohazord thanks i got it to work using ur solution

How can i limit the journey of a day to 17 h each day of calendar.
thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinmeyvaert picture kevinmeyvaert  路  4Comments

riflemanIm picture riflemanIm  路  3Comments

danielcruser picture danielcruser  路  3Comments

ivikash picture ivikash  路  5Comments

x1mrdonut1x picture x1mrdonut1x  路  5Comments