Opened 14 years ago
Closed 14 years ago
#1753 closed defect (fixed)
regist order impact the dnd result
Reported by: | Owned by: | Eugene Lazutkin | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | DnD | Version: | 0.4 |
Keywords: | dnd | Cc: | [email protected]… |
Blocked By: | Blocking: |
Description
When we create a dropTarget the dom node will be push to the dragManger's dropTargets array. Each time we start a dnd operation,dragManager will call its cacheTargetLocations() method to find out wich dropTarget should be consider. Then generate a dropTargetDimensions array.The dropTargetDimensions will then be used inside the findBestTarget() method.Here has two cases.
1.If we didn't set the dragManager's nestedTargets property,the dragManager will pick out the first node that containse the dragSource from the dropTargetDimensions.
2.If we set the dragManager's nestedTargets property to true,the dragManager will pick out the last node that containse the dragSource from the dropTargetDimensions.
In both of this cases,the order of calling dragManager's registerDropTarget method will impact the order of the node inside the dropTargetDimensions array which in turn impact the result of the dnd operation. So I think before return from dragManager's cacheTargetLocations() method,we should make a sort.The code maybe something like this:
cacheTargetLocations: function(){ dojo.profile.start("cacheTargetLocations"); this.dropTargetDimensions = []; dojo.lang.forEach(this.dropTargets, function(tempTarget){ var tn = tempTarget.domNode; //only cache dropTarget which can accept current dragSource if(!tn || (dojo.lang.find(tempTarget.acceptedTypes, "*") < 0 && dojo.lang.find(tempTarget.acceptedTypes, this.dragSource.type) < 0)){ return; } var abs = dojo.html.getAbsolutePosition(tn, true); var bb = dojo.html.getBorderBox(tn); this.dropTargetDimensions.push([ [abs.x, abs.y], // upper-left // lower-right [ abs.x+bb.width, abs.y+bb.height ], tempTarget ]); //dojo.debug("Cached for "+tempTarget) }, this); this.dropTargetDimensions.sort(some sort function based on Dimension) dojo.profile.end("cacheTargetLocations"); //dojo.debug("Cache locations") },
Change History (4)
comment:1 Changed 14 years ago by
Cc: | [email protected]… added |
---|
comment:2 Changed 14 years ago by
Milestone: | → 0.9 |
---|---|
Owner: | changed from psowden to alex |
comment:3 Changed 14 years ago by
Owner: | changed from alex to Eugene Lazutkin |
---|
It sounds like you are talking about overlapping drop targets? In that case, shouldn't it just pick the drop target on top? (Even if two drop targets have the same z-index, one is always on top)