Opened 13 years ago

Closed 12 years ago

#1753 closed defect (fixed)

regist order impact the dnd result

Reported by: cenyongh@… Owned by: Eugene Lazutkin
Priority: high Milestone: 0.9
Component: DnD Version: 0.4
Keywords: dnd Cc: cenyongh@…
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 13 years ago by bill

Cc: cenyongh@… added

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)

comment:2 Changed 13 years ago by dylan

Milestone: 0.9
Owner: changed from psowden to alex

comment:3 Changed 12 years ago by Adam Peller

Owner: changed from alex to Eugene Lazutkin

comment:4 Changed 12 years ago by Eugene Lazutkin

Resolution: fixed
Status: newclosed

Fixed in 0.9.

Note: See TracTickets for help on using tickets.