-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
51 lines (40 loc) · 1.91 KB
/
main.js
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
var ready = (callback) => {
if (document.readyState != "loading") callback();
else document.addEventListener("DOMContentLoaded", callback);
}
ready(() => {
document.querySelector(".header").style.height = window.innerHeight + "px";
adjustHeights();
//Forces images to fully load
})
$('.enter_link').click(function () {
$(this).parent('#splashscreen').fadeOut(500);
});
function getLineHeight() {
var r = document.querySelector(':root');
var rs = getComputedStyle(r);
console.log(rs.getPropertyValue('--line_height') )
}
function setLineHeight(height, height_name) {
var r = document.querySelector(':root');
r.style.setProperty(height_name, height + "px");
}
function getPosition(name){
var target = document.getElementById(name);
var rect = target.getBoundingClientRect();
console.log(rect.top, rect.right, rect.bottom, rect.left);
return [rect.top,rect.bottom];
}
function adjustHeights(){
setLineHeight(getPosition("icon_2")[0]-getPosition("icon_1")[1], '--line_height'); //Sets the height of line between two icons by taking the difference between both positions
setLineHeight(getPosition("icon_3")[0]-getPosition("icon_2")[1], '--line_height_2'); //Sets the height of line between two icons by taking the difference between both positions
setLineHeight(getPosition("icon_5")[0]-getPosition("icon_4")[1], '--line_height_3'); //Sets the height of line between two icons by taking the difference between both positions
setLineHeight(getPosition("icon_6")[0]-getPosition("icon_5")[1], '--line_height_4'); //Sets the height of line between two icons by taking the difference between both positions
}
var globalResizeTimer = null;
$(window).resize(function() {
if(globalResizeTimer != null) window.clearTimeout(globalResizeTimer);
globalResizeTimer = window.setTimeout(function() {
adjustHeights();
}, 100);
});