Is there any Task left resize event?


#1

Hello,
I want to know is there any event handler that will fire when a task is resized to the left side.

I want to know when a task is resized to it’s left side by dragging.


#2

Hello @Mohaimanul_Islam,

There is no specific event for exactly left resizing, but you can use the “onTaskDrag” event for this:
https://docs.dhtmlx.com/gantt/api__gantt_ontaskdrag_event.html

You can implement it using mode, original, and task parameters.

When you are resizing the task, the mode parameter will have the "resize" value(string), so you can use it to check if the task is resizing.

After that, you will have to check if it’s resizing by the left resizer
When you are resizing the task, you are changing it’s start_date(left drag). As the onTaskDrag provides the original(task before changes) and task(task after changes) parameters, you can compare their start dates, and if they are different - the event is resized by left resizer.

The code may look like follows:

gantt.attachEvent("onTaskDrag", function(id, mode, task, original){
  if(mode === "resize" && task.start_date !=  original.start_date){
    console.log("Left resize")
  }
  if(mode === "resize" && task.end_date != original.end_date){
    console.log("right resize")
  }
});

Here is the live demo:
http://snippet.dhtmlx.com/5/eba369713

List of available drag-and-drop modes:
https://docs.dhtmlx.com/gantt/api__gantt_drag_mode_config.html