Working code compatible with fullcalendar 2.6.1
I started this code from the post below ( A1rPun ).
JSFiddle Work
var scroll = -1; $('#calendar').fullCalendar({ // init calendar header: {left: 'today prev,next, refresh title', right: 'agendaDay,agendaWeek'}, allDaySlot: false, defaultView: 'agendaDay', // when all the events are rendered, scroll to the previous saved scroll position eventAfterAllRender: function(view) { if(scroll > -1 && (view.name=='agendaDay' || view.name=='agendaWeek')) setTimeout(function(){ document.querySelector('.fc-scroller').scrollTop = scroll; },0); }, // when view is destroyed, we keep the scroll position in a variable viewDestroy: function(view) { if(view.name=='agendaDay' || view.name=='agendaWeek') scroll = document.querySelector('.fc-scroller').scrollTop; } }); // end calendar
This solution works in AgendaDay and AgendaWeek modes. It also works when switching between them.
I don’t think it’s very nice, because you need to wait until all the events are displayed. The more events you have on the calendar, the longer it will take to scroll.
A good solution would be to use
Fullcalendar scrollTime option
You can set it to viewRender like this. This will cause the calendar to scroll to this time.
viewRender: function(view, element){ view.options.scrollTime = '09:00:00'; }
Perhaps there is a way to convert the scroll value in time and then display it on the calendar.
EDIT 1
I realized that it is much better to use viewRender callback instead of eventAfterAllRender callback to set the scroll position.
Here is the JSFiddle
viewRender: function(view, element){ if(scroll > -1 && (view.name=='agendaDay' || view.name=='agendaWeek')){ setTimeout(function(){ document.querySelector('.fc-scroller').scrollTop = scroll; },0); } },
This allows you to switch between other views (month, basicWeek ...) and save scrolling. And it's a little faster