aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/draggable/draggable_options.js
diff options
context:
space:
mode:
authorTJ VanToll <tj.vantoll@gmail.com>2013-01-26 15:31:27 -0500
committerTJ VanToll <tj.vantoll@gmail.com>2013-03-07 21:42:28 -0500
commit6358695df18722d8c7e99437365db42cf4957626 (patch)
treee4f9b9cab877b05457e4ae0fa470f2b49b019344 /tests/unit/draggable/draggable_options.js
parent5b2da7c127aa1afd9852063b6e4701ec6607e941 (diff)
downloadjquery-ui-6358695df18722d8c7e99437365db42cf4957626.tar.gz
jquery-ui-6358695df18722d8c7e99437365db42cf4957626.zip
Draggable: Fix border containment. Fixed #5569 - Draggable: Containment incorrectly calculates padding and border
Diffstat (limited to 'tests/unit/draggable/draggable_options.js')
-rw-r--r--tests/unit/draggable/draggable_options.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index ccbe7224a..2e9f85c24 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -346,6 +346,37 @@ test( "{ containment: 'parent' }, absolute", function() {
deepEqual( offsetAfter, expected, "compare offset to parent" );
});
+test( "containment, account for border", function() {
+ expect( 2 );
+
+ var el = $("#draggable1").appendTo("#main"),
+ parent = el.parent().css({
+ height: "100px",
+ width: "100px",
+ borderStyle: "solid",
+ borderWidth: "5px 10px 15px 20px"
+ }),
+ parentBottom = parent.offset().top + parent.outerHeight(),
+ parentRight = parent.offset().left + parent.outerWidth(),
+ parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ),
+ parentBorderRight = TestHelpers.draggable.border( parent, "right" );
+
+ el.css({
+ height: "5px",
+ width: "5px"
+ }).draggable({ containment: "parent" });
+
+ el.simulate( "drag", {
+ dx: 100,
+ dy: 100
+ });
+
+ equal( el.offset().top, parentBottom - parentBorderBottom - el.height(),
+ "The draggable should be on top of its parent's bottom border" );
+ equal( el.offset().left, parentRight - parentBorderRight - el.width(),
+ "The draggable should be to the right of its parent's right border" );
+});
+
test( "containment, default, switching after initialization", function() {
expect( 2 );