Created
April 5, 2016 15:04
-
-
Save mrkrand/d5683480c36513aaf84a69470932ee73 to your computer and use it in GitHub Desktop.
jQuery script thats toggles not-top class to body tag if user scrolls away
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
function pageNotTop() { | |
var notTop = false; | |
var body = jQuery('body'); | |
jQuery(document).scroll(function() { | |
if (jQuery(document).scrollTop() > 0) { | |
if (!notTop) { | |
notTop = true; | |
body.addClass('not-top'); | |
} | |
} else { | |
notTop = false; | |
body.removeClass('not-top'); | |
} | |
}); | |
} | |
pageNotTop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment