Skip to content
Permalink
Browse files

fix for #4439, offset.initialize can cause the page to jump

  • Loading branch information
brandonaaron committed Mar 30, 2009
1 parent 611d240 commit 2937d645cbf32e720d71f2f07f01e30fce0f9a88
Showing with 2 additions and 4 deletions.
  1. +2 −4 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(){};

0 comments on commit 2937d64

Please sign in to comment.
You can’t perform that action at this time.