Skip to content

Commit

Permalink
Drag: handle option to drag by center vs. corner
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesherov committed Aug 20, 2014
1 parent b91832e commit 386afd3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion jquery.simulate.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,24 @@ function findCenter( elem ) {
};
}

function findCorner( elem ) {
var offset,
document = $( elem.ownerDocument );
elem = $( elem );
offset = elem.offset();

return {
x: offset.left - document.scrollLeft(),
y: offset.top - document.scrollTop()
};
}

$.extend( $.simulate.prototype, {
simulateDrag: function() {
var i = 0,
target = this.target,
options = this.options,
center = findCenter( target ),
center = options.handle === "corner" ? findCorner( target ) : findCenter( target ),
x = Math.floor( center.x ),
y = Math.floor( center.y ),
dx = options.dx || 0,
Expand Down

0 comments on commit 386afd3

Please sign in to comment.