Skip to content

Instantly share code, notes, and snippets.

@ArtemSites
Created July 2, 2019 06:31
Show Gist options
  • Save ArtemSites/f2694e618a2d013be4a88a67e4d329c7 to your computer and use it in GitHub Desktop.
Save ArtemSites/f2694e618a2d013be4a88a67e4d329c7 to your computer and use it in GitHub Desktop.
Фиксация верхнего меню при прокручивании вниз.
var windowScroll = null;
var headerMenuNodePosition = headerMenuNode.offset().top;
var headerMenuNode = $('.js-header-menu');
$(window).on('scroll load', function () {
windowScroll = $(window).scrollTop();
if (windowScroll > headerMenuNodePosition) {
headerMenuNode.addClass(fixedClass);
} else {
headerMenuNode.removeClass(fixedClass);
}
});
// console.log(windowScroll);
// console.log(headerMenuNodePosition);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment