visjs / vis-timeline

📅 Create a fully customizable, interactive timelines and 2d-graphs with items and ranges.
https://visjs.github.io/vis-timeline/
Other
1.88k stars 317 forks source link

Rolling Mode and focus not working #573

Open andapop opened 4 years ago

andapop commented 4 years ago

I have rollingMode turned on and focus is not working anymore (works fine without rolling mode).

I've looked into it and it's probably doing the range set and then immediately scrolls bak to follow the current time.

I have managed to actually get it working in my code, by calling: timeline.range.stopRolling(); before i call timeline.focus(id);

(in the above code timeline is the vis timeline instance)

I think this could be fixed in the Timeline's focus function here https://github.com/visjs/vis-timeline/blob/3aefb0961acaa40b8000165a46084e8f46fe068f/lib/timeline/Timeline.js#L438 by just adding

if (this.range.rolling) {
      this.range.stopRolling();
}

before calling the setRange on line 534. Maybe there could be an extra option passed to the focus function, like there is for zoom, if you think this might break the desired behaviour in other cases.

c10b10 commented 1 year ago

Any progress on this?