Skip to content

Commit d0ea32e

Browse files
committed
Revert "Draggable: Set explicit width/height instead of right/bottom"
This reverts commit 8eca7b8. Fixes #10725
1 parent c770605 commit d0ea32e

File tree

3 files changed

+2
-50
lines changed

3 files changed

+2
-50
lines changed

tests/unit/draggable/draggable.html

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
<div id="main">
102102
<div id="draggable1" style="background: green; width: 200px; height: 100px; position: relative; top: 0; left: 0;">Relative</div>
103103
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
104-
<div id="draggable3" style="background: green; position: absolute; right: 5px; bottom: 5px; padding: 7px; border: 3px solid black;"><span><em>Absolute right-bottom</em></span></div>
105104
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
106105
<div id="main-forceScrollable"></div>
107106
</div>

tests/unit/draggable/draggable_core.js

+2-34
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ test( "element types", function() {
2525
el.append("<tr><td>content</td></tr>");
2626
}
2727

28-
// intrinsic height is incorrect in FF for buttons with no content
29-
// https://bugzilla.mozilla.org/show_bug.cgi?id=471763
30-
// Support: FF
31-
if ( typeName === "button" ) {
32-
el.text( "button" );
33-
}
34-
3528
el.draggable({ cancel: "" });
3629
offsetBefore = el.offset();
3730
el.simulate( "drag", {
@@ -42,8 +35,8 @@ test( "element types", function() {
4235

4336
// Support: FF, Chrome, and IE9,
4437
// there are some rounding errors in so we can't say equal, we have to settle for close enough
45-
closeEnough( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + "> left" );
46-
closeEnough( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + "> top" );
38+
closeEnough( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
39+
closeEnough( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
4740
el.draggable("destroy");
4841
el.remove();
4942
});
@@ -348,29 +341,4 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
348341
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
349342
});
350343

351-
// http://bugs.jqueryui.com/ticket/7772
352-
// when css 'right' is set, element resizes on drag
353-
test( "setting right/bottom css shouldn't cause resize", function() {
354-
expect( 4 );
355-
356-
var finalOffset,
357-
element = $( "#draggable3" ),
358-
origWidth = element.width(),
359-
origHeight = element.height(),
360-
origOffset = element.offset();
361-
362-
element.draggable();
363-
364-
TestHelpers.draggable.move( element, -50, -50 );
365-
366-
finalOffset = element.offset();
367-
finalOffset.left += 50;
368-
finalOffset.top += 50;
369-
370-
closeEnough( element.width(), origWidth, 1, "element retains width" );
371-
closeEnough( element.height(), origHeight, 1, "element retains height" );
372-
closeEnough( finalOffset.top, origOffset.top, "element moves the correct vertical distance" );
373-
closeEnough( finalOffset.top, origOffset.top, "element moves the correct horizontal distance" );
374-
});
375-
376344
})( jQuery );

ui/draggable.js

-15
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ $.widget("ui.draggable", $.ui.mouse, {
213213
$.ui.ddmanager.prepareOffsets(this, event);
214214
}
215215

216-
// Reset helper's right/bottom css if they're set and set explicit width/height instead
217-
// as this prevents resizing of elements with right/bottom set (see #7772)
218-
this._normalizeRightBottom();
219-
220216
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
221217

222218
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
@@ -659,17 +655,6 @@ $.widget("ui.draggable", $.ui.mouse, {
659655
}
660656
},
661657

662-
_normalizeRightBottom: function() {
663-
if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
664-
this.helper.width( this.helper.width() );
665-
this.helper.css( "right", "auto" );
666-
}
667-
if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
668-
this.helper.height( this.helper.height() );
669-
this.helper.css( "bottom", "auto" );
670-
}
671-
},
672-
673658
// From now on bulk stuff - mainly helpers
674659

675660
_trigger: function( type, event, ui ) {

0 commit comments

Comments
 (0)