Skip to content

Instantly share code, notes, and snippets.

@tkh44
Created June 6, 2012 18:47
Show Gist options
  • Save tkh44/2883844 to your computer and use it in GitHub Desktop.
Save tkh44/2883844 to your computer and use it in GitHub Desktop.
absolute - fixed scroller
$(document).ready(function() {
var nav = $('.compare_nav.fix_right');
nav.css({'position': 'absolute', 'right': '0px', 'top': '115px'});
$(window).scroll(function(e){
if($(this).scrollTop() > 200 && nav.css('position') != 'fixed') {
var wrapperLocation = $('#wrapper').offset()['left'];
var rightLocation = $('#wrapper').outerWidth() + wrapperLocation;
nav.css({'position': 'fixed', 'top': '115px', 'left': rightLocation - 200 + 'px'});
}
});
)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment