Draggable: Fix backCompat for scrollSpeed, scrollSensitivity, and containment as an array

This commit is contained in:
Mike Sherov 2013-03-04 11:43:49 -05:00
parent c341109388
commit fec3319b20
2 changed files with 23 additions and 14 deletions

View File

@ -19,8 +19,8 @@ TestHelpers.commonWidgetTests( "draggable", {
revert: false,
revertDuration: 500,
scroll: true,
scrollSensitivity: null,
scrollSpeed: null,
scrollSensitivity: 20,
scrollSpeed: 20,
scope: "default",
snap: false,
snapMode: "both",

View File

@ -481,7 +481,7 @@ $.widget( "ui.draggable", $.ui.draggable, {
},
_setContainment: function( event, ui ) {
var offset, left, top,
var offset, left, top, bottom, right,
container = this._getContainer();
if ( !container ) {
@ -489,19 +489,28 @@ $.widget( "ui.draggable", $.ui.draggable, {
return;
}
offset = container.offset();
left = offset.left +
(parseFloat( $.css( container[0], "borderLeftWidth", true ) ) || 0) +
(parseFloat( $.css( container[0], "paddingLeft", true ) ) || 0);
top = offset.top +
(parseFloat( $.css( container[0], "borderTopWidth", true ) ) || 0) +
(parseFloat( $.css( container[0], "paddingTop", true ) ) || 0);
if ( $.isArray( container ) ) {
offset = container.offset();
left = offset.left +
(parseFloat( $.css( container[0], "borderLeftWidth", true ) ) || 0) +
(parseFloat( $.css( container[0], "paddingLeft", true ) ) || 0);
top = offset.top +
(parseFloat( $.css( container[0], "borderTopWidth", true ) ) || 0) +
(parseFloat( $.css( container[0], "paddingTop", true ) ) || 0);
right = left + container.width();
bottom = top + container.height();
} else {
left = container[ 0 ];
top = container[ 1 ];
right = container[ 2 ];
bottom = container[ 3 ];
}
this.containment = {
left: left,
top: top,
right: left + container.width(),
bottom: top + container.height(),
right: right,
bottom: bottom,
leftDiff: ui.originalOffset.left - ui.originalPosition.left,
topDiff: ui.originalOffset.top - ui.originalPosition.top,
width: this.dragDimensions.width,
@ -937,8 +946,8 @@ if ( $.uiBackCompat !== false ) {
$.widget( "ui.draggable", $.ui.draggable, {
options: {
scroll: true,
scrollSpeed: null,
scrollSensitivity: null
scrollSpeed: 20,
scrollSensitivity: 20
},
_create : function() {
var self = this,