Search code examples
jqueryjquery-uijquery-ui-draggablejquery-ui-droppable

jQuery Draggable, use left side possible?


I have a grid whereby draggable objects can be dropped onto the grid. The draggable objects are generally larger than the grid.

My problem is that when an object is dropped, it uses the center of the object to determine where it was dropped. In order to get the alignment correct I want it to work out where it was dropped based on the left side of the object and not the center. Any ideas?


Solution

  • I have resolved this by adding this to the draggable: cursorAt: { left: 0 }, And adding this to the droppable: tolerance: "pointer". This makes the cursor decide which droppable to use not the center of the div and by putting the cursor on the left I can be specific to an exact grid item.