summaryrefslogtreecommitdiff
path: root/js/application.js
blob: cd7cf0c94975d39c94e56c07046b9784c2406688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(function ($) {

	$(function(){

		// fix sub nav on scroll
		var $win = $(window),
				$nav = $('.subnav'),
				navHeight = $('.navbar').first().height(),
				navTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
				isFixed = 0;

		processScroll();

		$win.on('scroll', processScroll);

		function processScroll() {
			var i, scrollTop = $win.scrollTop();
			if (scrollTop >= navTop && !isFixed) {
				isFixed = 1;
				$nav.addClass('subnav-fixed');
			} else if (scrollTop <= navTop && isFixed) {
				isFixed = 0;
				$nav.removeClass('subnav-fixed');
			}
		}

	});

})(window.jQuery);