Lighthouse-io / react-visjs-timeline

React component for the vis.js timeline module
MIT License
210 stars 91 forks source link

How would I implement the timeline.setWindow() function to react-visjs-timeline? #51

Open davidfufu opened 6 years ago

davidfufu commented 6 years ago

I can't find a way to make the timeline zoom into a specific level of zoom. I looked over the source code, and I've thought of creating a method like

setWindow = (start, end ) => {
     timeline.setWindow(start, end);
}

But, I can't think of a way to expose an internal method of a component that could be accessed when importing the component. Need some help on this if anyone has any ideas.

jtrinklein commented 6 years ago

@davidfufu I have a PR to expose the vis.js timeline element that you might find helpful: https://github.com/Lighthouse-io/react-visjs-timeline/pull/52

mojjy commented 6 years ago

I like @jtrinklein implementation, but that does not seem available at present, I worked around it this manner

constuctor() { this.timeline = React.createRef(); this.zoomIn = this.zoomIn.bind(this); }

` render() {

} `

zoomIn() { this.timeline.current.$el.zoomIn(0.2) }

nasir-awan commented 5 years ago

ZoomIn, ZoomOut does not work - it always reset to options.start and options.end

this.timeline.current.$el.zoomIn(0.2)

msimonian77 commented 4 years ago

Does anyone know what is the new way to set the timeline element? There is no $el in the new vis-timeline. I tried timeline.current.timeline.zoomIn(0.2) as it's where I saw the zoomIn but it didn't work.