core/skin/virtual-nt.ru/js/themejs/toppanel.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-02-25 22:58:56 +05:00
$(window).on("load", function() {
responsiveLayout();
});
//responsiveLayout Menu
var responsiveflagMenu = false;
function responsiveLayout(element,eclass){
var $header = $("header"),
offset_top = $header.offset().top;
$(window).scroll(function(event){
processScroll($header, "navbar-compact", offset_top);
});
responsiveflagMenu = true;
}
// processScroll Menu
function processScroll(element, eclass, offset_top) {
var scrollTop = $(window).scrollTop();
if($(element).height()< $(window).height()){
if (scrollTop > offset_top) {
//fix secondary navigation
$(element).addClass(eclass);
} else if (scrollTop <= offset_top) {
$(element).removeClass(eclass);
}
}
}
$(window).load(function() {
var lastScrollTop = 0;
$(window).scroll(function(event) {
var $header = $("header");
var scrTop = $(window).scrollTop();
//hidden menu
$header.addClass('hidden-menu');
if( scrTop > lastScrollTop ) {
if($header.hasClass('navbar-compact')) {
$header.addClass('hidden-menu');
}
} else {
if($header.hasClass('navbar-compact')) {
$header.removeClass('hidden-menu');
}
}
lastScrollTop = scrTop;
});
});