Skip to content

Commit

Permalink
Ensure course menu width when fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
raphendyr committed Jul 23, 2018
1 parent 1c7bcee commit e3648a2
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions assets/js/aplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,30 @@ $(function() {

var modifyMenu = function() {
var menu = $('#main-course-menu');
if ($(window).scrollTop() > menuHeight && !menuFixed) {
if (!menuFixed && $(window).scrollTop() > menuHeight) {
var w = menu.width();
menu.addClass('fixed');
menu.css('width', ""+w+"px");
menuFixed = true;
} else if ($(window).scrollTop() < 50 && menuFixed) {
} else if (menuFixed && $(window).scrollTop() < 50) {
menu.removeClass('fixed');
menu.css('width', '');
menuFixed = false;
}
};

$(window).bind('scroll', function () {
modifyMenu();
});

$(window).bind('resize', function () {
modifyMenu();
});
var updateMenu = function() {
var menu = $('#main-course-menu');
if (menuFixed) {
menu.removeClass('fixed');
menu.css('width', '');
menuFixed = false;
modifyMenu();
}
};

$(window).bind('scroll', modifyMenu);
$(window).bind('resize', updateMenu);
});

/**
Expand Down

0 comments on commit e3648a2

Please sign in to comment.