2011-03-22 17:12:03 +00:00
|
|
|
(function( $ ) {
|
|
|
|
|
2011-05-03 08:38:17 +00:00
|
|
|
function scrollTopSupport() {
|
2011-05-12 20:48:01 +00:00
|
|
|
$( window ).scrollTop( 1 );
|
2011-05-03 08:38:17 +00:00
|
|
|
return $( window ).scrollTop() === 1;
|
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
module( "position" );
|
|
|
|
|
|
|
|
test( "my, at, of", function() {
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 40, left: 40 }, "left top, left top" );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left bottom",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 60, left: 40 }, "left top, left bottom" );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left",
|
|
|
|
at: "bottom",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 55, left: 50 }, "left, bottom" );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left foo",
|
|
|
|
at: "bar baz",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 45, left: 50 }, "left foo, bar baz" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "multiple elements", function() {
|
|
|
|
var elements = $( "#el1, #el2" );
|
2010-01-07 03:19:50 +00:00
|
|
|
var result = elements.position({
|
2011-03-22 17:12:03 +00:00
|
|
|
my: "left top",
|
|
|
|
at: "left bottom",
|
|
|
|
of: "#parent",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
same( result, elements );
|
|
|
|
var expected = { top: 10, left: 4 };
|
2010-01-07 03:19:50 +00:00
|
|
|
elements.each(function() {
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( this ).offset(), expected );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "positions", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
var definitions = [];
|
|
|
|
var offsets = {
|
|
|
|
left: 0,
|
|
|
|
center: 3,
|
|
|
|
right: 6,
|
|
|
|
top: 0,
|
|
|
|
bottom: 6
|
|
|
|
};
|
|
|
|
var start = { left: 4, top: 4 };
|
2011-03-22 17:12:03 +00:00
|
|
|
$.each( [ 0, 1 ], function( my ) {
|
|
|
|
$.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
|
|
|
|
$.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
definitions.push({
|
2011-03-22 17:12:03 +00:00
|
|
|
my: my ? horizontal + " " + vertical : "left top",
|
|
|
|
at: !my ? horizontal + " " + vertical : "left top",
|
2010-01-07 03:19:50 +00:00
|
|
|
result: {
|
2011-03-22 17:12:03 +00:00
|
|
|
top: my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ],
|
|
|
|
left: my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ]
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
var el = $( "#el1" );
|
|
|
|
$.each( definitions, function( index, definition ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
el.position({
|
|
|
|
my: definition.my,
|
|
|
|
at: definition.at,
|
2011-03-22 17:12:03 +00:00
|
|
|
of: "#parent",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( el.offset(), definition.result,
|
|
|
|
"Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "of", function() {
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 40, left: 40 }, "selector" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left bottom",
|
|
|
|
of: $( "#parentx"),
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 60, left: 40 }, "jQuery object" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
|
|
|
of: $( "#parentx" )[ 0 ],
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 40, left: 40 }, "DOM element" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "right bottom",
|
|
|
|
at: "right bottom",
|
2010-01-07 03:19:50 +00:00
|
|
|
of: document,
|
2011-03-22 17:12:03 +00:00
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
|
|
|
top: $( document ).height() - 10,
|
|
|
|
left: $( document ).width() - 10
|
|
|
|
}, "document" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "right bottom",
|
|
|
|
at: "right bottom",
|
|
|
|
of: $( document ),
|
|
|
|
collision: "none"
|
2010-08-27 17:34:14 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
|
|
|
top: $( document ).height() - 10,
|
|
|
|
left: $( document ).width() - 10
|
|
|
|
}, "document as jQuery object" );
|
|
|
|
|
|
|
|
$( window ).scrollTop( 0 );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "right bottom",
|
|
|
|
at: "right bottom",
|
2010-01-07 03:19:50 +00:00
|
|
|
of: window,
|
2011-03-22 17:12:03 +00:00
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
|
|
|
top: $( window ).height() - 10,
|
|
|
|
left: $( window ).width() - 10
|
|
|
|
}, "window" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "right bottom",
|
|
|
|
at: "right bottom",
|
|
|
|
of: $( window ),
|
|
|
|
collision: "none"
|
2010-08-27 17:34:14 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
|
|
|
top: $( window ).height() - 10,
|
|
|
|
left: $( window ).width() - 10
|
|
|
|
}, "window as jQuery object" );
|
|
|
|
|
2011-05-03 08:38:17 +00:00
|
|
|
if ( scrollTopSupport() ) {
|
2011-03-22 17:12:03 +00:00
|
|
|
$( window ).scrollTop( 500 ).scrollLeft( 200 );
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "right bottom",
|
|
|
|
at: "right bottom",
|
2011-02-26 10:23:37 +00:00
|
|
|
of: window,
|
2011-03-22 17:12:03 +00:00
|
|
|
collision: "none"
|
2011-02-26 10:23:37 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
|
|
|
top: $( window ).height() + 500 - 10,
|
|
|
|
left: $( window ).width() + 200 - 10
|
|
|
|
}, "window, scrolled" );
|
|
|
|
$( window ).scrollTop( 0 ).scrollLeft( 0 );
|
2011-02-26 10:23:37 +00:00
|
|
|
}
|
2011-03-22 17:12:03 +00:00
|
|
|
|
|
|
|
var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
2010-01-07 03:19:50 +00:00
|
|
|
of: event,
|
2011-03-22 17:12:03 +00:00
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
2010-01-07 03:19:50 +00:00
|
|
|
top: 300,
|
|
|
|
left: 200
|
2011-03-22 17:12:03 +00:00
|
|
|
}, "event - left top, left top" );
|
|
|
|
|
|
|
|
event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } );
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "right bottom",
|
2010-01-07 03:19:50 +00:00
|
|
|
of: event,
|
2011-03-22 17:12:03 +00:00
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), {
|
2010-01-07 03:19:50 +00:00
|
|
|
top: 600,
|
|
|
|
left: 400
|
2011-03-22 17:12:03 +00:00
|
|
|
}, "event - left top, right bottom" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "offsets", function() {
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left+10 bottom+10",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2011-03-22 16:25:25 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 70, left: 50 }, "offsets in at" );
|
|
|
|
|
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left+10 top-10",
|
|
|
|
at: "left bottom",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2011-03-22 16:25:25 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 50, left: 50 }, "offsets in my" );
|
2011-03-22 16:25:25 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left+50% bottom-10%",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2011-03-22 16:25:25 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 58, left: 50 }, "percentage offsets in at" );
|
2011-03-22 16:25:25 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).position({
|
|
|
|
my: "left-30% top+50%",
|
|
|
|
at: "left bottom",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2011-03-22 16:25:25 +00:00
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" );
|
2011-03-22 16:25:25 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "using", function() {
|
|
|
|
expect( 6 );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
|
|
|
var count = 0,
|
2011-03-22 17:12:03 +00:00
|
|
|
elems = $( "#el1, #el2" ),
|
2010-01-07 03:19:50 +00:00
|
|
|
expectedPosition = { top: 40, left: 40 },
|
|
|
|
originalPosition = elems.position({
|
2011-03-22 17:12:03 +00:00
|
|
|
my: "right bottom",
|
|
|
|
at: "rigt bottom",
|
|
|
|
of: "#parentx",
|
|
|
|
collision: "none"
|
2010-01-07 03:19:50 +00:00
|
|
|
}).offset();
|
2011-03-22 17:12:03 +00:00
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
elems.position({
|
2011-03-22 17:12:03 +00:00
|
|
|
my: "left top",
|
|
|
|
at: "left top",
|
|
|
|
of: "#parentx",
|
|
|
|
using: function( position ) {
|
|
|
|
same( this, elems[ count ], "correct context for call #" + count );
|
|
|
|
same( position, expectedPosition, "correct position for call #" + count );
|
2010-01-07 03:19:50 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
});
|
2011-03-22 17:12:03 +00:00
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
elems.each(function() {
|
2011-03-22 17:12:03 +00:00
|
|
|
same( $( this ).offset(), originalPosition, "elements not moved" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
function collisionTest( config, result, msg ) {
|
|
|
|
var elem = $( "#elx" ).position( $.extend({
|
2010-01-07 03:19:50 +00:00
|
|
|
my: "left top",
|
|
|
|
at: "right bottom",
|
|
|
|
of: window
|
2011-03-22 17:12:03 +00:00
|
|
|
}, config ) );
|
|
|
|
same( elem.offset(), result, msg );
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
function collisionTest2( config, result, msg ) {
|
|
|
|
collisionTest( $.extend({
|
2010-01-07 03:19:50 +00:00
|
|
|
my: "right bottom",
|
|
|
|
at: "left top"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, config ), result, msg );
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: fit, no offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: 0, left: 0 }, "left top" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: fit, with offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "fit",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "right+2 bottom+3"
|
2010-01-07 03:19:50 +00:00
|
|
|
}, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
|
2011-03-22 17:12:03 +00:00
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "fit",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "left+2 top+3"
|
|
|
|
}, { top: 0, left: 0 }, "left top, positive offset" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "fit",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "left-2 top-3"
|
|
|
|
}, { top: 0, left: 0 }, "left top, negative offset" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-05-03 08:38:17 +00:00
|
|
|
test( "collision: fit, window scrolled", function() {
|
|
|
|
if ( scrollTopSupport() ) {
|
|
|
|
var win = $( window );
|
2011-05-16 23:46:21 +00:00
|
|
|
win.scrollTop( 300 ).scrollLeft( 200 );
|
|
|
|
|
2011-05-03 08:38:17 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "fit",
|
|
|
|
at: "left-100 top-100"
|
|
|
|
}, { top: 300, left: 200 }, "top left" );
|
|
|
|
collisionTest2({
|
|
|
|
collision: "fit",
|
|
|
|
at: "right+100 bottom+100"
|
|
|
|
}, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" );
|
2011-05-16 23:46:21 +00:00
|
|
|
|
2011-05-03 08:38:17 +00:00
|
|
|
win.scrollTop( 0 ).scrollLeft( 0 );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: flip, no offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "flip"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: -10, left: -10 }, "left top" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "flip"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height(), left: $( window ).width() }, "right bottom" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: flip, with offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "flip",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "right+2 bottom+3"
|
|
|
|
}, { top: -13, left: -12 }, "left top, with offset added" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "flip",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "left+2 top+3"
|
|
|
|
}, { top: $( window ).height() - 3, left: $( window ).width() - 2 }, "bottom, positive offset" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "flip",
|
2011-05-12 20:44:24 +00:00
|
|
|
at: "left-2 top-3"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, negative offset" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: none, no offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "none"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height(), left: $( window ).width() }, "left top" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "none"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: -10, left: -10 }, "moved to the right bottom" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: none, with offset", function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest({
|
|
|
|
collision: "none",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "right+2 bottom+3"
|
|
|
|
}, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, with offset added" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "none",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "left+2 top+3"
|
|
|
|
}, { top: -7, left: -8 }, "left top, positive offset" );
|
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
collisionTest2({
|
|
|
|
collision: "none",
|
2011-03-22 17:12:03 +00:00
|
|
|
at: "left-2 top-3"
|
|
|
|
}, { top: -13, left: -12 }, "left top, negative offset" );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: fit, with margin", function() {
|
|
|
|
$( "#elx" ).css( "margin", 10 );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest2({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: 10, left: 10 }, "left top" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).css({
|
2010-09-03 14:38:44 +00:00
|
|
|
"margin-left": 5,
|
|
|
|
"margin-top": 5
|
|
|
|
});
|
|
|
|
|
|
|
|
collisionTest({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest2({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: 5, left: 5 }, "left top" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
$( "#elx" ).css({
|
2010-09-03 14:38:44 +00:00
|
|
|
"margin-right": 15,
|
|
|
|
"margin-bottom": 15
|
|
|
|
});
|
|
|
|
|
|
|
|
collisionTest({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() - 25, left: $( window ).width() - 25 }, "right bottom" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest2({
|
|
|
|
collision: "fit"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: 5, left: 5 }, "left top" );
|
2010-09-03 14:38:44 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
test( "collision: flip, with margin", function() {
|
|
|
|
$( "#elx" ).css( "margin", 10 );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest({
|
|
|
|
collision: "flip",
|
|
|
|
at: "left top"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "left top" );
|
2010-09-03 14:38:44 +00:00
|
|
|
|
|
|
|
collisionTest2({
|
|
|
|
collision: "flip",
|
|
|
|
at: "right bottom"
|
2011-03-22 17:12:03 +00:00
|
|
|
}, { top: 0, left: 0 }, "right bottom" );
|
2010-09-03 14:38:44 +00:00
|
|
|
});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
//test( "bug #5280: consistent results (avoid fractional values)", function() {
|
|
|
|
// var wrapper = $( "#bug-5280" ),
|
2010-03-26 23:53:43 +00:00
|
|
|
// elem = wrapper.children(),
|
|
|
|
// offset1 = elem.position({
|
2011-03-22 17:12:03 +00:00
|
|
|
// my: "center",
|
|
|
|
// at: "center",
|
2010-03-26 23:53:43 +00:00
|
|
|
// of: wrapper,
|
2011-03-22 17:12:03 +00:00
|
|
|
// collision: "none"
|
2010-03-26 23:53:43 +00:00
|
|
|
// }).offset(),
|
|
|
|
// offset2 = elem.position({
|
2011-03-22 17:12:03 +00:00
|
|
|
// my: "center",
|
|
|
|
// at: "center",
|
2010-03-26 23:53:43 +00:00
|
|
|
// of: wrapper,
|
2011-03-22 17:12:03 +00:00
|
|
|
// collision: "none"
|
2010-03-26 23:53:43 +00:00
|
|
|
// }).offset();
|
2011-03-22 17:12:03 +00:00
|
|
|
// same( offset1, offset2 );
|
2010-03-26 23:53:43 +00:00
|
|
|
//});
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
}( jQuery ) );
|