jQuery's drag and drop - reverse engineering Facebook's uiTokenizer on 'Arts & Interests' jQuery's drag and drop - reverse engineering Facebook's uiTokenizer on 'Arts & Interests' jquery jquery

jQuery's drag and drop - reverse engineering Facebook's uiTokenizer on 'Arts & Interests'


It looks like you are just determining if the draggables right intersects the targets left, and if the draggables top intersects the targets bottom (with some tolerance).

There are 2 ways I would go about this:

  1. Find all intersect elements and find the largest area - in this case the left square of the image below.
  2. If the draggable has the same dimensions as the droppable the 1/4 overlap would suffice - in this case the right square.

enter image description here

The second is by far the easiest to implement but is no means as general as the first.So by having a quick look through your code, I would loop through all the "possible" droppable elements determine the area of the overlap and target the largest.