Skip to content

Commit fec3319

Browse files
committed
Draggable: Fix backCompat for scrollSpeed, scrollSensitivity, and containment as an array
1 parent c341109 commit fec3319

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

tests/unit/draggable/draggable_common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ TestHelpers.commonWidgetTests( "draggable", {
1919
revert: false,
2020
revertDuration: 500,
2121
scroll: true,
22-
scrollSensitivity: null,
23-
scrollSpeed: null,
22+
scrollSensitivity: 20,
23+
scrollSpeed: 20,
2424
scope: "default",
2525
snap: false,
2626
snapMode: "both",

ui/jquery.ui.draggable.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -481,27 +481,36 @@ $.widget( "ui.draggable", $.ui.draggable, {
481481
},
482482

483483
_setContainment: function( event, ui ) {
484-
var offset, left, top,
484+
var offset, left, top, bottom, right,
485485
container = this._getContainer();
486486

487487
if ( !container ) {
488488
this.containment = null;
489489
return;
490490
}
491491

492-
offset = container.offset();
493-
left = offset.left +
494-
(parseFloat( $.css( container[0], "borderLeftWidth", true ) ) || 0) +
495-
(parseFloat( $.css( container[0], "paddingLeft", true ) ) || 0);
496-
top = offset.top +
497-
(parseFloat( $.css( container[0], "borderTopWidth", true ) ) || 0) +
498-
(parseFloat( $.css( container[0], "paddingTop", true ) ) || 0);
492+
if ( $.isArray( container ) ) {
493+
offset = container.offset();
494+
left = offset.left +
495+
(parseFloat( $.css( container[0], "borderLeftWidth", true ) ) || 0) +
496+
(parseFloat( $.css( container[0], "paddingLeft", true ) ) || 0);
497+
top = offset.top +
498+
(parseFloat( $.css( container[0], "borderTopWidth", true ) ) || 0) +
499+
(parseFloat( $.css( container[0], "paddingTop", true ) ) || 0);
500+
right = left + container.width();
501+
bottom = top + container.height();
502+
} else {
503+
left = container[ 0 ];
504+
top = container[ 1 ];
505+
right = container[ 2 ];
506+
bottom = container[ 3 ];
507+
}
499508

500509
this.containment = {
501510
left: left,
502511
top: top,
503-
right: left + container.width(),
504-
bottom: top + container.height(),
512+
right: right,
513+
bottom: bottom,
505514
leftDiff: ui.originalOffset.left - ui.originalPosition.left,
506515
topDiff: ui.originalOffset.top - ui.originalPosition.top,
507516
width: this.dragDimensions.width,
@@ -937,8 +946,8 @@ if ( $.uiBackCompat !== false ) {
937946
$.widget( "ui.draggable", $.ui.draggable, {
938947
options: {
939948
scroll: true,
940-
scrollSpeed: null,
941-
scrollSensitivity: null
949+
scrollSpeed: 20,
950+
scrollSensitivity: 20
942951
},
943952
_create : function() {
944953
var self = this,

0 commit comments

Comments
 (0)