aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrandon Aaron <brandon.aaron@gmail.com>2009-03-30 07:59:31 +0000
committerBrandon Aaron <brandon.aaron@gmail.com>2009-03-30 07:59:31 +0000
commit2937d645cbf32e720d71f2f07f01e30fce0f9a88 (patch)
tree87cc0a70ed58937830af0fb39d252a2c4ec4950e /src
parent611d24086c3837da21e0816fa3cb7b826f28da87 (diff)
downloadjquery-2937d645cbf32e720d71f2f07f01e30fce0f9a88.tar.gz
jquery-2937d645cbf32e720d71f2f07f01e30fce0f9a88.zip
fix for #4439, offset.initialize can cause the page to jump
Diffstat (limited to 'src')
-rw-r--r--src/offset.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/offset.js b/src/offset.js
index 9ef5aa02d..1ee140585 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -52,7 +52,7 @@ else
jQuery.offset = {
initialize: function() {
- var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = body.style.marginTop,
+ var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = parseFloat(jQuery.curCSS(body, 'marginTop', true), 10) || 0,
html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';
jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } );
@@ -71,9 +71,7 @@ jQuery.offset = {
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
- body.style.marginTop = '1px';
- this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0);
- body.style.marginTop = bodyMarginTop;
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
body.removeChild(container);
jQuery.offset.initialize = function(){};