aboutsummaryrefslogtreecommitdiffstats
path: root/tests/jquery.simulate.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2013-01-12 00:33:45 -0500
committerMike Sherov <mike.sherov@gmail.com>2013-03-04 01:05:11 -0500
commitc278a4461b399c5b84abf4e03c1d902bfd130441 (patch)
tree7982633aec7b9c658a72de0524dbd1848a676add /tests/jquery.simulate.js
parent6d3a1e1fe8cc21f385456ea26075f3909136a589 (diff)
downloadjquery-ui-c278a4461b399c5b84abf4e03c1d902bfd130441.tar.gz
jquery-ui-c278a4461b399c5b84abf4e03c1d902bfd130441.zip
Draggable Tests: Add test coverage for supported options
Diffstat (limited to 'tests/jquery.simulate.js')
-rw-r--r--tests/jquery.simulate.js22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js
index 0ae88c20f..6e2f3ba8e 100644
--- a/tests/jquery.simulate.js
+++ b/tests/jquery.simulate.js
@@ -277,18 +277,30 @@ 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,
- dy = options.dy || 0,
- moves = options.moves || 3,
- coord = { clientX: x, clientY: y };
+ coord = { clientX: x, clientY: y },
+ dx = options.dx || ( options.x !== undefined ? options.x - x : 0 ),
+ dy = options.dy || ( options.y !== undefined ? options.y - y : 0 ),
+ moves = options.moves || 3;
this.simulateEvent( target, "mousedown", coord );