Scroll position update

I mostly use the timeline view.

I have scroll_position: new Date(Date.now()) and autoscroll is also enabled. This works pretty well once the scheduler gets rendered.

This only happens once, but I would like to have the scroll_position to always match the actual time.
This is probably possible by creating a setInverval function every 60 seconds to send a new scroll_position to the scheduler.
Is there otherwise any other way to achieve this?

I also would like to have this function active only if i’m not scrolling the timeline to a different position than the current time.
ex1: If I move the timeline to the future/past -> scroll_position is not synchronized with current time -> function to scroll position to the current time OFF
ex2: If scroll_position is synchronized with current_time -> function to scroll position to the current time ON

Is there any object returning the scroll_position value in timeframe?

After digging into scheduler, I found that there is no way to get a scroll position based on time.
But, I created a work around.

So for the most curious here’s a description:
1st step - Create an event with an ID you’ll remember. In my case the 26. Don’t provide any section_id, this way it will never be assigned. This event will be like the tracking point.
2nd step - Create a setInterval to update this Event (26) location. In my case every 60 seconds. The location has the start_date as a reference. This way the timeline will always have a tracking point with the current time.

setInterval(function(){
					var eventId = scheduler.addEvent({
						start_date: new Date,
						end_date:   new Date(Date.now() + 60000),
						description:   "timeline position", 
						id:26,
						section_idi:'',
						first_name:'',
						last_name:''
					});
            },60000);

3rd step - create an attachEvent onAfterUpdate to scroll you to the latest location of Event 26

 dp.attachEvent("onAfterUpdate", function(id, action, tid, response){
                            if(id == 26){
                                var event_date = scheduler.getEvent(26).start_date;
                                scheduler.getView('timeline').scrollTo(event_date);
                            }
                            return true;
                        }); 

With this done, your timeline will scroll by it self without you having to scroll it.
I’ve also created a second solution for in case someone manually scrolls the timeline to stop the autoscroll and reactivate it after pressing the ESC key, which scrolls you again to the current “start_date”.

1 Like