Skip to content

Instantly share code, notes, and snippets.

@Wilto
Created December 13, 2011 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wilto/1472946 to your computer and use it in GitHub Desktop.
Save Wilto/1472946 to your computer and use it in GitHub Desktop.
Scott Jehl/Kangax’s fixed positioning test
$.support.positionFixed = (function (){
var contain = $( document.documentElement );
if ( 'getBoundingClientRect' in contain[0] ) {
var el = $( "<div style='position:fixed;top:100px;'>x</div>" ).appendTo( contain ),
originalHeight = contain[ 0 ].style.height,
w = window,
result;
contain.height( screen.height * 2 + "px" );
w.scrollTo( 0, 100 );
result = el[ 0 ].getBoundingClientRect().top === 100;
contain.height( originalHeight );
el.remove();
w.scrollTo( 0, 0 );
return result;
}
return false;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment