blob: f960d92f3f98323f41258f4c21879194185e793e (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
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);
menu = $('#barTopMenu').remove();
if (is_below_the_fold) {
menu.append(
$('.action-menu-list li', menu)
.remove()
.addClass('from-action-menu')
);
menu.appendTo('#barBottomLeft');
} else {
$('.action-menu-list', menu).append(
$('.from-action-menu', menu)
.remove()
.removeClass('from-action-menu')
);
menu.prependTo('#flex-header');
NavigationShrinker();
$('#barTopMenu-toggle').prop('checked', false);
}
was_below_the_fold = is_below_the_fold;
}
};
const HeaderMagic = {
enable() {
fold = $('#flex-header').height();
Scroll.addHandler('header', scroll);
},
disable() {
Scroll.removeHandler('header');
$('body').removeClass('fixed');
}
};
export default HeaderMagic;
|