Opened 13 years ago

Closed 11 years ago

#3831 closed feature (duplicate)

Add new tolerance options for small droppables

Reported by: kquinn Owned by: paul
Priority: trivial Milestone: 1.9.0
Component: ui.droppable Version: 1.6rc4
Keywords: Cc:
Blocked by: Blocking:


The current tolerance options for droppables seem to assume the droppable is smaller than the draggable, and aren't very useful if the draggable is larger. I propose two additional tolerance options: 'enclose', which triggers if the droppable is fully inside the draggable, and 'overlap', which triggers if the draggable overlaps the center of the droppable. I have found 'overlap' in particular to be very useful for my application.

Sample implementations are provided below. They are simple enough that I do not claim any copyright over them. They can be inserted into the case statement in $.ui.intersect that begins "switch (toleranceMode) {":

		case 'enclose':		//test if draggable completely encloses droppable
			return (x1 <= l && x2 >= r &&
				y1 <= t && y2 >= b);
		case 'overlap':		//test if draggable overlaps center of droppable
			return (x2 > l + (droppable.proportions.width / 2)	
				&& x1 < l + (droppable.proportions.width / 2)	
				&& y1 < t + (droppable.proportions.height / 2)	
				&& y2 > t + (droppable.proportions.height / 2));	

I would like to see these or similar options added to future UI releases.

Change History (3)

comment:1 Changed 13 years ago by Jörn Zaefferer

Milestone: TBD1.8

Looks very useful to me, just needs some testing.

comment:2 Changed 13 years ago by Cloudream

Owner: set to paul
Status: newassigned

comment:3 Changed 11 years ago by Scott González

Resolution: duplicate
Status: assignedclosed

Closing as duplicate of #4737 since that will allow you to implement any intersection mode you want.

Note: See TracTickets for help on using tickets.