onBeforeTaskChanged
Description
Fires after the user has finished dragging and released the mouse button but before the changes are applied
onBeforeTaskChanged: (id: string | number, mode: string, task: Task) => boolean;
Parameters
id- (required) string | number - the task idmode- (required) string - the drag-and-drop mode ("resize", "progress", "move", "ignore")task- (required) Task - the copy of the task object in its original state (before drag and drop)
Returns
result- (boolean) - defines whether the default action of the event will be triggered (true) or canceled (false)
Example
gantt.attachEvent("onBeforeTaskChanged", function(id, mode, task){
//any custom logic here
return true;
});
Details
- The event fires when the user drags a task in the timeline area.
- The event is blockable. Return false to cancel the drag operation.
- The event fires before the onAfterTaskDrag event.
The task argument contains the original (not modified) task object, while the same data object available via the gantt.getTask(id) method is already modified. This object can be used to check the exact changes made by drag and drop compared to the initial state of the task - e.g. whether duration increased or decreased, start date moved forward or backward, etc. If false is returned from the method, the task object in gantt will rollback to the values from the original task object.