forked from zombieFox/nightTab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.js
More file actions
75 lines (70 loc) · 2.33 KB
/
Copy pathheader.js
File metadata and controls
75 lines (70 loc) · 2.33 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var header = (function() {
var _bind = function() {
window.addEventListener("resize", function() {
render();
}, false);
window.addEventListener("scroll", function() {
render();
}, false);
helper.eA(".container").forEach(function(arrayItem, index) {
arrayItem.addEventListener("transitionend", function() {
render();
}, false);
});
};
var render = function() {
var html = helper.e("html");
var header = helper.e(".header");
var link = helper.e(".link");
var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
var scrollPosition = document.documentElement.scrollTop;
var _margin = function() {
var height = parseInt(getComputedStyle(header).height, 10);
var marginValue;
if (state.get().background.image.show && (state.get().header.shade.show && state.get().header.shade.style == "always") || state.get().header.shade.style == "always" || state.get().header.shade.border.bottom) {
marginValue = (height + fontSize);
} else {
marginValue = height;
};
html.style.setProperty("--header-height", marginValue + "px");
};
var _color = function() {
if (state.get().header.shade.show) {
if (state.get().header.shade.style == "always") {
html.style.setProperty("--header-shade-color", "var(--gray-01)");
} else if (state.get().header.shade.style == "scroll") {
if (scrollPosition > (fontSize * 2)) {
html.style.setProperty("--header-shade-color", "var(--gray-01)");
} else {
html.style.setProperty("--header-shade-color", "transparent");
};
} else {
html.style.setProperty("--header-shade-color", "transparent");
};
} else {
html.style.setProperty("--header-shade-color", "transparent");
};
};
var _opacity = function() {
if (state.get().header.shade.show) {
html.style.setProperty("--header-shade-opacity", state.get().header.shade.opacity);
};
};
var _padding = function() {
html.style.setProperty("--header-shade-padding", state.get().header.shade.padding);
};
_color();
_opacity();
_padding();
_margin();
};
var init = function() {
_bind();
render();
};
// exposed methods
return {
init: init,
render: render
};
})();