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
50 lines (44 loc) · 1.31 KB
/
Copy pathheader.js
File metadata and controls
50 lines (44 loc) · 1.31 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
var header = (function() {
var _bind = function() {
window.addEventListener("resize", function(event) {
render();
}, false);
window.addEventListener("scroll", function(event) {
_addHeaderBackground();
}, false);
helper.eA(".container").forEach(function(arrayItem, index) {
arrayItem.addEventListener("transitionend", function() {
render();
}, false);
});
};
var _addHeaderBackground = function() {
var html = helper.e("html");
var header = helper.e(".header");
var scrollPosition = document.documentElement.scrollTop;
var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
if (scrollPosition > (fontSize * 2)) {
helper.addClass(header, "header-background");
} else {
helper.removeClass(header, "header-background");
};
};
var render = function() {
var html = helper.e("html");
var header = helper.e(".header");
var link = helper.e(".link");
var height = parseInt(getComputedStyle(header).height, 10);
// var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
// link.style.marginTop = (height + fontSize) + "px";
link.style.marginTop = height + "px";
};
var init = function() {
_bind();
render();
};
// exposed methods
return {
init: init,
render: render
};
})();