onTaskDrag
Description
Fires when the user drags a task
onTaskDrag: (id: string | number, mode: string, task: Task, original: Task, e: Event) => void;
Parameters
id- (required) string | number - the task idmode- (required) string - the drag mode ("resize", "progress", "move", "ignore")task- (required) Task - the current (dragged) task objectoriginal- (required) Task - the original(initial) task objecte- (required) Event - a native event object
Example
gantt.attachEvent("onTaskDrag", function(id, mode, task, original){
//any custom logic here
});
Related samples
Details
The event:
- Fires each time the user makes a drag movement with the mouse in the timeline area: moves, resizes a task or changes the task's progress.
- The type of a drag movement is passed as the 2nd argument - mode.
- All available values of the drag movement's type are stored in the drag_mode property.
Shortly, all happens in the following order:
- The user makes a move.
- dhtmlxGantt recalculates the task's date according to the new position.
- dhtmlxGantt fires the onTaskDrag event.
- dhtmlxGantt re-renders the task in the Gantt chart.