Ticket #2136 (closed bug: fixed)
Draggables aren't correctly contained in parent
|Reported by:||Pete Michaud||Owned by:||codesquare|
Draggable elements with containment set to parent, can only move where their parent starts out: the area doesn't update as the parent dimensions change.
The reason for this is that the draggable function defines the bounding box in terms of 4 points calculated at the time of the call. If the parent is, for example, a div that has its dimensions defined as percentages, then the containment will fail on window resize, because the containment area will stay the same while the actual element changes.
Currently it's possible to work around this by destroying the draggables and calling it again on resize. It should also be possible to get the draggable instance and manually calculate the points and assign them, also on resize (that would be a cheaper option, I think).
The problem I see is determining when the box should be recalculated--I have described one situation where the bounding box changes, but other scenarios are possible as well. What if the parent is manipulated directly by a script?
I'm not sure what the best approach is because many approaches could get expensive -- maybe we should provide an OPTION to hook in to the parent's resize event.