You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
853 B
35 lines
853 B
(function ($) {
|
|
|
|
$(function(){
|
|
|
|
// fix sub nav on scroll
|
|
var $win = $(window),
|
|
$body = $('body'),
|
|
$nav = $('.subnav'),
|
|
navHeight = $('.navbar').first().height(),
|
|
subnavHeight = $('.subnav').first().height(),
|
|
subnavTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
|
|
marginTop = parseInt($body.css('margin-top'), 10);
|
|
isFixed = 0;
|
|
|
|
processScroll();
|
|
|
|
$win.on('scroll', processScroll);
|
|
|
|
function processScroll() {
|
|
var i, scrollTop = $win.scrollTop();
|
|
|
|
if (scrollTop >= subnavTop && !isFixed) {
|
|
isFixed = 1;
|
|
$nav.addClass('subnav-fixed');
|
|
$body.css('margin-top', marginTop + subnavHeight + 'px');
|
|
} else if (scrollTop <= subnavTop && isFixed) {
|
|
isFixed = 0;
|
|
$nav.removeClass('subnav-fixed');
|
|
$body.css('margin-top', marginTop + 'px');
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
})(window.jQuery);
|