Select Git revision
header_magic.js
Forked from
Stud.IP / Stud.IP
1544 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
header_magic.js 683 B
import NavigationShrinker from './navigation_shrinker.js';
import Scroll from './scroll.js';
let fold;
let was_below_the_fold = false;
const scroll = function(scrolltop) {
var is_below_the_fold = scrolltop > fold,
menu;
if (is_below_the_fold !== was_below_the_fold) {
$('body').toggleClass('fixed', is_below_the_fold);
was_below_the_fold = is_below_the_fold;
}
};
const HeaderMagic = {
enable() {
fold = $('#navigation-level-1').height();
Scroll.addHandler('header', scroll, true);
},
disable() {
Scroll.removeHandler('header');
$('body').removeClass('fixed');
}
};
export default HeaderMagic;