Search code examples
javascriptvis.js-timeline

How to get rolling mode state from vis timeline


Is there a way to determine the current state of rollingMode of the timeline? (or keep track of all events toggeling the rollingMode?)

If I start in rollingMode but a user drags the timeline rollingMode is toggled to off. I tested and I can catch that with the rangechanged event and checking the byUser variable. But I did not find any event for the user clicking on the blue reset button which toggles rollingMode to on. Nor did I find anything to inquire the timeline object directly.

My use case is a timeline that runs in rolling mode as default. It also has some input fields to display a time range determined by the user input. In the second scenario rolling mode needs to be switched off. If I can't keep track of the current state of rollingMode I can not use toggleRollingMode() when switching view modes for my user.

Thanks


Solution

  • The rolling mode state of the timeline can be determined like this:

    timeline.range.rolling
    

    Reference:
    https://github.com/visjs/vis-timeline/blob/master/lib/timeline/Timeline.js#L735