From 4b9d5d1b5bd36726c6e49b105c0f75649cca1ae4 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Fri, 3 Sep 2010 10:38:44 -0400 Subject: Position: Take margin into account when performing collisions. Fixes #5766 - position: collision should take margin into account. --- tests/unit/position/position_core.js | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'tests/unit/position') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 426231ee3..f4075ccfe 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -354,6 +354,58 @@ test("collision: none, with offset", function() { }, { top: -13, left: -12 }, "left top, negative offset"); }); +test("collision: fit, with margin", function() { + $("#elx").css("margin", 10); + + collisionTest({ + collision: "fit" + }, { top: $(window).height() - 20, left: $(window).width() - 20 }, "right bottom"); + + collisionTest2({ + collision: "fit" + }, { top: 10, left: 10 }, "left top"); + + $("#elx").css({ + "margin-left": 5, + "margin-top": 5 + }); + + collisionTest({ + collision: "fit" + }, { top: $(window).height() - 20, left: $(window).width() - 20 }, "right bottom"); + + collisionTest2({ + collision: "fit" + }, { top: 5, left: 5 }, "left top"); + + $("#elx").css({ + "margin-right": 15, + "margin-bottom": 15 + }); + + collisionTest({ + collision: "fit" + }, { top: $(window).height() - 25, left: $(window).width() - 25 }, "right bottom"); + + collisionTest2({ + collision: "fit" + }, { top: 5, left: 5 }, "left top"); +}); + +test("collision: flip, with margin", function() { + $("#elx").css("margin", 10); + + collisionTest({ + collision: "flip", + at: "left top" + }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "left top"); + + collisionTest2({ + collision: "flip", + at: "right bottom" + }, { top: 0, left: 0 }, "right bottom"); +}); + //test('bug #5280: consistent results (avoid fractional values)', function() { // var wrapper = $('#bug-5280'), // elem = wrapper.children(), -- cgit v1.2.3