Opened 15 years ago
Closed 14 years ago
#370 closed defect (fixed)
DND does not work when dragging onto a panel with another under lying dragtarget
Reported by: | Owned by: | psowden | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | DnD | Version: | 0.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
DND does not work when dragging onto a panel with another under lying dragtarget.
From a quick look at the HtmlDragManager?, it looks like findBestTarget does not take z-index into account
Change History (4)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Component: | General → DnD |
---|---|
Milestone: | → 0.5 |
Owner: | changed from anonymous to psowden |
comment:3 Changed 14 years ago by
This above fix still works as of 0.4, but i'm currently using the following modification to the findBestTarget method, which is a bit cleaner:
findBestTarget: function(e) { var _this = this; var bestBox = new Object(); bestBox.target = null; bestBox.points = null; var bestArea = null; dojo.lang.every(this.dropTargetDimensions, function(tmpDA) { if(!_this.isInsideBox(e, tmpDA)){ return true; } if(!_this.nestedTargets) { bestBox.target = tmpDA[2]; bestBox.points = tmpDA; } else { var area = tmpDA[1][0] * tmpDA[1][1]; if(bestArea===null || area < bestArea) { bestArea = area; bestBox.target = tmpDA[2]; bestBox.points = tmpDA; } } // continue iterating only if _this.nestedTargets == true return Boolean(_this.nestedTargets); }); return bestBox; },
I'm currently adding this into the code I'm working on with the following snippet, which is a bit longer than the previous one, but more efficient:
/* Fix to allow the priority selection of DropTargets that have the smallest area first */ if(dojo.dnd.dragManager.nestedTargets) { dojo.dnd.dragManager.findBestTarget = dojo.lang.hitch(dojo.dnd.dragManager,function(e) { var _this = this; var bestBox = new Object(); bestBox.target = null; bestBox.points = null; var bestArea = null; dojo.lang.every(this.dropTargetDimensions, function(tmpDA) { if(!_this.isInsideBox(e, tmpDA)){ return true; } if(!_this.nestedTargets) { bestBox.target = tmpDA[2]; bestBox.points = tmpDA; } else { var area = tmpDA[1][0] * tmpDA[1][1]; if(bestArea===null || area < bestArea) { bestArea = area; bestBox.target = tmpDA[2]; bestBox.points = tmpDA; } } // continue iterating only if _this.nestedTargets == true return Boolean(_this.nestedTargets); }); return bestBox; }); }
Note: See
TracTickets for help on using
tickets.
I've been using this fix to solve a similar problem where i'd like the nested targets to be chosen based on the smallest area first, it should be easy to modify it to work based on Z-Index instead. (This was tested against trunk)