blob: d4e7848d9053dd30d336435cdca85873757923e6 (
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
|
import Scroll from './scroll.js';
let fold;
let was_below_the_fold = false;
const scroll = function(scrolltop) {
const is_below_the_fold = scrolltop > fold;
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;
|