Created
January 5, 2012 12:00
-
-
Save rutger1140/1564976 to your computer and use it in GitHub Desktop.
Fix position of element when scrollheight is met
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make position fixed after scrollheight is met | |
$(window).scroll(function(e){ | |
var scrollTo = 180; | |
var scrollClass = '#gf_page_steps_3'; | |
$el = $(scrollClass); | |
position = $el.position(); | |
if ($(this).scrollTop() > scrollTo && $el.css('position') != 'fixed'){ | |
$(scrollClass).css({'position': 'fixed', 'top': '20px'}); | |
} else if ((position.top < scrollTo) && ($el.css('position') != 'relative')){ | |
$(scrollClass).css({'position': 'relative', 'top': '0px'}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment