Created
January 17, 2020 14:04
-
-
Save koderhun/5ed04b37017166d2260685a476171446 to your computer and use it in GitHub Desktop.
Фиксация header при обратной прокрутке.
This file contains hidden or 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
$(window).on("scroll", function() { | |
var fromTop = $(document).scrollTop(); | |
if (docPos > fromTop) { | |
$body.toggleClass("header-fix", fromTop > 20); | |
} else { | |
$body.removeClass("header-fix"); | |
} | |
if (fromTop > 105) { | |
$body.addClass("header-hide"); | |
} else { | |
$body.removeClass("header-hide"); | |
} | |
docPos = fromTop; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment