2019-01-03 23:30:27 +01:00
|
|
|
var header = (function() {
|
|
|
|
|
|
|
|
var _bind = function() {
|
2019-02-16 23:27:54 +01:00
|
|
|
window.addEventListener("resize", function() {
|
2019-01-03 23:30:27 +01:00
|
|
|
render();
|
|
|
|
}, false);
|
2019-02-16 23:27:54 +01:00
|
|
|
window.addEventListener("scroll", function() {
|
|
|
|
render();
|
2019-01-24 21:28:11 +01:00
|
|
|
}, 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-04-03 13:47:41 +02:00
|
|
|
var edge = function(action) {
|
|
|
|
var header = helper.e(".header");
|
|
|
|
var container = helper.makeNode({
|
|
|
|
tag: "div",
|
|
|
|
attr: [{
|
|
|
|
key: "class",
|
|
|
|
value: "header-edge"
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
var state = {
|
|
|
|
show: function() {
|
|
|
|
header.appendChild(container);
|
|
|
|
},
|
|
|
|
hide: function() {
|
|
|
|
header.removeChild(helper.e(".header-edge"));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
state[action]();
|
|
|
|
};
|
|
|
|
|
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");
|
2019-02-16 23:27:54 +01:00
|
|
|
var fontSize = parseInt(getComputedStyle(html).fontSize, 10);
|
|
|
|
var scrollPosition = document.documentElement.scrollTop;
|
|
|
|
var _margin = function() {
|
|
|
|
var height = parseInt(getComputedStyle(header).height, 10);
|
|
|
|
var marginValue;
|
2019-04-04 12:19:43 +02:00
|
|
|
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.show) {
|
2019-02-16 23:27:54 +01:00
|
|
|
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() {
|
2019-04-04 12:13:07 +02:00
|
|
|
html.style.setProperty("--header-shade-padding-multiplier-top", state.get().header.shade.padding.top);
|
|
|
|
html.style.setProperty("--header-shade-padding-multiplier-bottom", state.get().header.shade.padding.bottom);
|
|
|
|
};
|
|
|
|
var _border = function() {
|
|
|
|
html.style.setProperty("--header-border-width-multiplier-top", state.get().header.shade.border.top.width);
|
|
|
|
html.style.setProperty("--header-border-width-multiplier-bottom", state.get().header.shade.border.bottom.width);
|
2019-02-16 23:27:54 +01:00
|
|
|
};
|
|
|
|
_color();
|
|
|
|
_opacity();
|
|
|
|
_padding();
|
2019-04-04 12:13:07 +02:00
|
|
|
_border();
|
2019-02-16 23:27:54 +01:00
|
|
|
_margin();
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
_bind();
|
|
|
|
render();
|
|
|
|
};
|
|
|
|
|
|
|
|
// exposed methods
|
|
|
|
return {
|
2019-04-03 13:47:41 +02:00
|
|
|
edge: edge,
|
|
|
|
render: render,
|
|
|
|
init: init
|
2019-01-03 23:30:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|