Change menu

This commit is contained in:
Roman Pyrih
2025-11-12 12:45:24 +01:00
parent 4113c42da7
commit cd823a3b8c
9 changed files with 163 additions and 16 deletions

View File

@@ -2,3 +2,45 @@
* Custom code goes here.
* A template should always ship with an empty custom.js
*/
jQuery(window).on('load', function () {
var $ = jQuery;
var $box = $('.nav_menu_box');
if (!$box.length) return;
var boxTop = 0;
var boxHeight = 0;
function recalc() {
boxTop = $box.offset().top;
boxHeight = $box.outerHeight();
}
function onScroll() {
if ($(window).width() <= 767) {
$box.removeClass('box_fixed');
$('#header').css('margin-bottom', 0);
return;
}
var scrollTop = $(window).scrollTop();
if (scrollTop >= boxTop) {
$box.addClass('box_fixed');
$('#header').css('margin-bottom', boxHeight);
} else {
$box.removeClass('box_fixed');
$('#header').css('margin-bottom', 0);
}
}
$(window).on('resize', function () {
recalc();
onScroll();
});
$(window).on('scroll', onScroll);
recalc();
onScroll();
});