I've made a nav on my site which is absolute positioned.
I've made a class to make this fixed to the top of the screen.
What I'm trying to find out is how to carry out a function (toggleClass in this instance) after the windows has been scrolled x amount of pixels down the page (500 px in this instance)
The procedure is:
Assuming jQuery, something like this:
$(window).on('scroll', function() {
scrollPosition = $(this).scrollTop();
if (scrollPosition >= 500) {
// If the function is only supposed to fire once
$(this).off('scroll');
// Other function stuff here...
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With