Commit 6176f1b1 authored by Thomas Park's avatar Thomas Park
Browse files

clean up javascript code

parent e9b46a94
!function ($) {
(function ($) {
$(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
// fix sub nav on scroll
var $win = $(window),
$nav = $('.subnav'),
navHeight = $('.navbar').first().height(),
navTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
isFixed = 0;
processScroll()
processScroll();
$win.on('scroll', 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')
}
}
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)
\ No newline at end of file
})(window.jQuery);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment