Restrict child task to be dragged problem

I have used the code which restricts child task to be dragged before and after parent task. When I drag within day time scale, it is fine. However, when I drag within week, month and year scales, the child task can be dragged before parent task for 1 day or two days, and after parent task for 1 day or two days too. How to prevent it? This is my code:

[code]gantt.attachEvent(“onTaskDrag”, function(id, mode, task, original){
var modes = gantt.config.drag_mode;
var parent = gantt.getTask(task.parent);
if(mode == modes.move || mode == modes.resize){

                var diff = original.duration*(1000*60*60*24);
         
                if(+task.end_date > +parent.end_date){
                    task.end_date = new Date(parent.end_date);
                    if(mode == modes.move)
                        task.start_date = new Date(task.end_date - diff);
                    }
                if(+task.start_date < +parent.start_date){
                    task.start_date = new Date(parent.start_date);
                    if(mode == modes.move)
                        task.end_date = new Date(+task.start_date + diff);
                }
            }                
            return true;
        });         [/code]

sorry, is dragged beyond before parent task and beyond after parent task. Forget to mention beyond.

Hello,
try the latest build of the component from this post, your code seems working correctly with it
viewtopic.php?f=15&t=20507&start=10