Opened 13 years ago

Closed 9 years ago

#4781 closed feature (duplicate)

Patch: force draggable's containment property to update during drag

Reported by: AJI Owned by:
Priority: minor Milestone: 2.0.0
Component: ui.draggable Version: 1.7.2
Keywords: containment Cc:
Blocked by: Blocking:


The containment property for a draggable cannot be changed while the element is being dragged. This patch resets the containment during the drag.

Use case: a draggable element mimics a slider on a horizontal graph that can be stretched. When the draggable reaches one end of the graph, the graph widens. The slider is custom contained to the left half of the graph.

If the slider element widens the graph, its containment area will appear to shrink.

With this patch, client code can recalculate the containment area during the drag so that the containment area is maintained at half of the total width.

Patch for ui.draggable.js.

        _mouseDrag: function(event, noPropagation) {

            /// PATCH START ///
            var o = this.options;
            //Set a containment if given in the options
            if (o.containment)
            //Recache the helper size
            /// PATCH END ///

            //Compute the helpers position
            this.position = this._generatePosition(event);
            this.positionAbs = this._convertPositionTo("absolute");

Change History (6)

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

Milestone: TBD1.8

comment:2 Changed 10 years ago by Scott González

Type: enhancementfeature

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


comment:4 Changed 10 years ago by Jörn Zaefferer

Status: newopen

Need to take this usecase into account for 2.0.0, not necessarily the solution.

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

This should be handled by refresh().

comment:6 Changed 9 years ago by Scott González

Resolution: duplicate
Status: openclosed

Duplicate of #4911.
We're not going to implement this as requested, but rather as part of the upcoming refresh() method. Therefore, I'm closing as s duplicate.

Note: See TracTickets for help on using tickets.