Hi there - I have tried to implement a scrollTo feature so when the ScheduleComponent mounts it automatically scrolls to the current time, but it is not working -- nothing happens. Additionally, two more questions:
Hi Jessica,
Q1: I have tried to implement a scrollTo feature so when the
ScheduleComponent mounts it automatically scrolls to the current time, but it
is not working -- nothing happens?
We have prepared a sample to scrollTo. The attached sample below demonstrates the solution. Please give it a try and let us know if you need any further assistance.
Sample: https://stackblitz.com/edit/schedule-daterangechange-sample-xwiwts?file=index.js
|
const Views = () => { const scheduleObj = useRef(null); const dayDiffrents = 4; const [currentView, setCurrentView] = useState(''); const [selectedDate, setSelectedDate] = useState(new Date(2021, 1, 15)); useEffect(() => { const daysDifference = dayDiffrents; if (daysDifference < 0) { return; } else if (daysDifference === 0) { setCurrentView('Day'); } else if (daysDifference > 0 && daysDifference <= 6) { setCurrentView('Week'); } else if (daysDifference > 6) { setCurrentView('Month'); } scheduleObj.current.selectedDate = new Date(2021, 1, 15); console.log(scheduleObj.current.selectedDate); // setSelectedDate(new Date(2021, 1, 17)); }, []);
const onCreated = () => { // If you want to scroll through time, you can use the scrollTo method as below. scheduleObj.current.scrollTo('07:00'); // If you want to scroll through Date, you can use the scrollTo method as below. scheduleObj.current.scrollTo(null, new Date(2021, 2, 5)); }
|
Q2: Would you be able to assist with formatting the SimpleBar to display
horizontally? I have the behavior working vertically?
Providing more details will greatly help us understand and resolve the
problem.
Q3: When setting the current view in my useEffect, I am trying to set the
selectedDate via the scheduleObjRef (i.e. scheduleObjRef.current.selectedDate =
period.from()), but I get an error: Cannot set properties of null (setting
'selectedDate'). I am following the answer to this forum I opened?
We have created a sample based on the shared details, and it is functioning
properly. We suspect that there may be an issue during the rendering of the
schedule control, where the DOM may not load properly or load late, resulting
in the observed issues. Kindly share a runnable sample with us or provide a
video. This information will significantly aid us in understanding and
resolving the problem.
Regards,
Ashok