Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ui/jquery.ui.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ $.widget("ui.draggable", $.ui.mouse, {
//Create and append the visible helper
this.helper = this._createHelper(event);

//Cache the element's size
this._cacheElementProportions();

//Cache the helper size
this._cacheHelperProportions();

Expand Down Expand Up @@ -351,6 +354,13 @@ $.widget("ui.draggable", $.ui.mouse, {
};
},

_cacheElementProportions: function() {
this.elementProportions = {
width: this.element.outerWidth(),
height: this.element.outerHeight()
};
},

_cacheHelperProportions: function() {
this.helperProportions = {
width: this.helper.outerWidth(),
Expand Down Expand Up @@ -418,6 +428,17 @@ $.widget("ui.draggable", $.ui.mouse, {
var pageX = event.pageX;
var pageY = event.pageY;

// Correct for cloned element dimension differences
if ( this.helper.options == 'clone' && !this.helperProportions.width && !this.helperProportions.height ) {
this._cacheHelperProportions();
var xAspect = this.helperProportions.width / this.elementProportions.width,
yAspect = this.helperProportions.height / this.elementProportions.height;
if ( xAspect && yAspect ) {
this.offset.click.left *= xAspect;
this.offset.click.top *= yAspect;
}
}

/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
Expand Down