2019-01-03 23:30:27 +01:00
|
|
|
var header = (function() {
|
|
|
|
|
|
|
|
var _bind = function() {
|
|
|
|
window.addEventListener("resize", function(event) {
|
|
|
|
render();
|
|
|
|
}, false);
|
2019-01-24 21:28:11 +01:00
|
|
|
window.addEventListener("scroll", function(event) {
|
|
|
|
_addHeaderBackground();
|
|
|
|
}, false);
|
2019-01-15 13:49:10 +01:00
|
|
|
helper.eA(".container").forEach(function(arrayItem, index) {
|
|
|
|
arrayItem.addEventListener("transitionend", function() {
|
|
|
|
render();
|
|
|
|
}, false);
|
|
|
|
});
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
2019-01-24 21:28:11 +01:00
|
|
|
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");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-01-03 23:30:27 +01:00
|
|
|
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);
|
2019-01-24 21:28:11 +01:00
|
|
|
// var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
|
|
|
|
// link.style.marginTop = (height + fontSize) + "px";
|
|
|
|
link.style.marginTop = height + "px";
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
_bind();
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
|
|
|
init: init,
|
|
|
|
render: render
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|