Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10660 closed bug (duplicate)

Draggable containment area is calculated on start and never updated

Reported by: Novac Owned by:
Priority: minor Milestone: none
Component: ui.draggable Version: 1.10.4
Keywords: Cc:
Blocked by: Blocking:

Description

When you set containment on a draggable object, the containment area is set on drag start and is not updated if new elements are added.

The error occurs if you do the following:

  • Set containment option
  • On drag start, insert element into containment area, e.g. a row
  • Try to drag the draggable element into the new row (still located within the containment area, but added after drag start)

I have created a JSFiddle to show the problem. However, this is the first time using JSFiddle and I couldn't find JQuery UI in the version I was using, but it does illustrate the problem.

http://jsfiddle.net/mLc0bnbL/3/

I suggest one of the following:

  • Update containment area in the drag event (Could see this being a performance hit)
  • Set the containment area after the start event has been triggered.
  • Provide a method to run _setContainment manually

Change History (2)

comment:1 Changed 5 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #4911.
This will be addressed in the rewrite with the refresh() method.

comment:2 Changed 3 years ago by Rouven Bauer

This might do the trick inside the event handler

$(this).data('uiDraggable')._cacheHelperProportions();
$(this).data('uiDraggable')._setContainment();
Note: See TracTickets for help on using tickets.