I am using Fullcalendar V5. While trying to set the scrollTime to the current date and time in the resourceTimelineWeek view, time only is working fine, but how shall I set the date scrolling.
var scrollTime = moment().format("HH") + ":00:00";
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
now: new Date(),
scrollTime: scrollTime
}
)};
Now, it is 09:30 and the time is showing correctly. But the date is Oct 01, which is still Sep 27 on the calendar scroll view.
Tested on FullCalendar 5.8.0 (using jQuery and moment.js)
options = {
datesSet: ({ view }) => {
if (view.type === 'resourceTimelineWeek') {
const scroller = $('.fc-scrollgrid-section-body .fc-scroller').last();
const [date] = moment().toISOString().split(':');
const position = $(`.fc-timeline-slot[data-date^="${date}"]`).last().position();
if (position) {
scroller.scrollLeft(position.left);
}
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.