Dragging the timeline area


#1

Hi there guys!

As the tittle (loosely) states, I want to implement a drag feature that will work the same way as
the horizontal scroll.

Is there a built in option for that?

Thanks in advance,
SChatz


#2

Hello @SChatz,
There is no built-in functionality for this, but it is possible to implement this feature, using the following methods and functions:
getScrollState:
https://docs.dhtmlx.com/gantt/api__gantt_getscrollstate.html?_ga=2.228896475.676904631.1573458571-548090258.1568021691
scrollTo:
https://docs.dhtmlx.com/gantt/api__gantt_scrollto.html?_ga=2.228896475.676904631.1573458571-548090258.1568021691
onMouseMove:
https://docs.dhtmlx.com/gantt/api__gantt_onmousemove_event.html?_ga=2.228896475.676904631.1573458571-548090258.1568021691
Main steps of this solution:

  1. Get the mouse position right after the click
  2. Detect how the mouse position changes(onMouseMove).
  3. Get the scroll position(getScrollState)
  4. Add the difference between mouse positions to the scrolling position(scrollTo(difference))

Here is an example of how it could be implemented:
http://snippet.dhtmlx.com/e2502e87e


#3

Thanks for the solution.