new offset method, faster and no more browser detection
This commit is contained in:
parent
b64d60940d
commit
5c21e44fce
3 changed files with 112 additions and 94 deletions
24
test/data/offset/body.html
Normal file
24
test/data/offset/body.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>body</title>
|
||||
<style type="text/css" media="screen">
|
||||
body { margin: 1px; padding: 5px; }
|
||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||
</style>
|
||||
<script type="text/javascript" src="../../../dist/jquery.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
$(function() {
|
||||
$('body').click(function() {
|
||||
$('#marker').css( $(this).offset() );
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="marker"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -126,10 +126,10 @@ if ( !jQuery.browser.msie || (jQuery.browser.msie && parseInt(jQuery.browser.ver
|
|||
var $w = testwin["fixed"].$;
|
||||
|
||||
equals( $w('#fixed-1').offset().top, 1001, "jQuery('#fixed-1').offset().top" );
|
||||
equals( $w('#fixed-1').offset().left, jQuery.browser.msie ? 994 : 1001, "jQuery('#fixed-1').offset().left" );
|
||||
equals( $w('#fixed-1').offset().left, 1001, "jQuery('#fixed-1').offset().left" );
|
||||
|
||||
equals( $w('#fixed-2').offset().top, 1021, "jQuery('#fixed-2').offset().top" );
|
||||
equals( $w('#fixed-2').offset().left, jQuery.browser.msie ? 1014 : 1021, "jQuery('#fixed-2').offset().left" );
|
||||
equals( $w('#fixed-2').offset().left, 1021, "jQuery('#fixed-2').offset().left" );
|
||||
|
||||
testwin["fixed"].close();
|
||||
});
|
||||
|
@ -161,4 +161,13 @@ testwin("scroll", function() {
|
|||
equals( $w('#scroll-1-1').offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
testwin["scroll"].close();
|
||||
});
|
||||
|
||||
testwin("body", function() {
|
||||
var $w = testwin["body"].$;
|
||||
|
||||
equals( $w('body').offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equals( $w('body').offset().left, 1, "jQuery('#body').offset().left" );
|
||||
|
||||
testwin["body"].close();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue