Skip to content

Commit 386afd3

Browse files
committed
Drag: handle option to drag by center vs. corner
1 parent b91832e commit 386afd3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

jquery.simulate.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,24 @@ function findCenter( elem ) {
279279
};
280280
}
281281

282+
function findCorner( elem ) {
283+
var offset,
284+
document = $( elem.ownerDocument );
285+
elem = $( elem );
286+
offset = elem.offset();
287+
288+
return {
289+
x: offset.left - document.scrollLeft(),
290+
y: offset.top - document.scrollTop()
291+
};
292+
}
293+
282294
$.extend( $.simulate.prototype, {
283295
simulateDrag: function() {
284296
var i = 0,
285297
target = this.target,
286298
options = this.options,
287-
center = findCenter( target ),
299+
center = options.handle === "corner" ? findCorner( target ) : findCenter( target ),
288300
x = Math.floor( center.x ),
289301
y = Math.floor( center.y ),
290302
dx = options.dx || 0,

0 commit comments

Comments
 (0)