Vertical drag is not working properly


#1

Even after unsuccessful drag it is replicating the the taskbar. how can i fix this? how to give more accuracy to the drag function
video for reference : -

http://snippet.dhtmlx.com/5/1e10e6739


#2

Hello Nitish,
Gantt doesn’t have a built-in feature to vertically reorder tasks in the timeline. In the snippet, you only have an example of the implementation, so it is expected that it may not work correctly in every use case.

There are 2 ways why duplicate tasks may be created.

  1. The task is moved to the same vertical position. That can be easily fixed if we cancel the drag and don’t use the code to create a new task:
      if (id == target_task.id) {
        dragging_task = 0;
        gantt.updateTask(id)
        gantt.render()
        return
      }

Here is the updated snippet:
http://snippet.dhtmlx.com/5/1c988cdf2
2) When you move a task to a task row that has the task type, the target task becomes the project task. The initial target task is cloned and displayed as the split task. When you move all tasks from that row, the project task becomes a regular task. You need to decide if you want to delete that task or not.
If you want to do that, you need to check the number of child tasks after a timeout and delete that task if it doesn’t have any children:

        if (children.length == 1) {
          original_parent.type = gantt.config.types.task;
          setTimeout(function(){
            if (!gantt.hasChild(original_parent.id)) {
              gantt.deleteTask(original_parent.id);
            }
          }, 20)
        }

Here is the snippet:
http://snippet.dhtmlx.com/5/215cf1b1c

Please, note, that it is still not an ideal solution, and you may encounter some issues in the different use cases.