Change menu
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user