-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
107 lines (95 loc) · 3.29 KB
/
script.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import Highway from '@dogstudio/highway';
import Fade from './transition'
const H = new Highway.Core({
transitions: {
default: Fade
}
});
const preload = document.querySelector('.preload')
const burger = document.querySelector('.burger')
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');
const logo = document.querySelector('.logo');
const mclose = document.querySelectorAll('.mclose')
const openModalButtons = document.querySelectorAll('[data-modal-target]');
const closeModalButtons = document.querySelectorAll('[data-close-button]');
const overlay = document.getElementById('overlay')
const lfade = document.querySelector('.logo')
const modal = document.getElementById('modal')
const load = () => {
window.addEventListener('load', () => {
preload.classList.add("preload-finish");
});
}
const mClose = () => {
mclose.forEach(button => {
button.addEventListener('click', () => {
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = ''
} else {
link.style.animation = `navLinkFade 0.1s ease forwards ${index /3 + 1.5}s`;
}
});
if (nav.classList.contains('nav-active'),
burger.classList.contains('toggle'),
logo.classList.contains('activate')) {
nav.classList.remove('nav-active');
burger.classList.remove('toggle');
logo.classList.remove('activate');
} else {
nav.classList.add('nav-active');
burger.classList.add('toggle');
logo.classList.add('activate');
}
})
})
burger.addEventListener('click', () => {
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = ''
} else {
link.style.animation = `navLinkFade 0.5s ease forwards ${index /3 + 1.5}s`;
}
});
if (nav.classList.contains('nav-active'),
burger.classList.contains('toggle'),
logo.classList.contains('activate')) {
nav.classList.remove('nav-active');
burger.classList.remove('toggle');
logo.classList.remove('activate');
} else {
nav.classList.add('nav-active');
burger.classList.add('toggle');
logo.classList.add('activate');
}
})
}
const disModal = () => {
openModalButtons.forEach(button => {
button.addEventListener('click', () => {
openModal(modal)
})
});
closeModalButtons.forEach(button => {
button.addEventListener('click', () => {
const modal = button.closest('.modal')
closeModal(modal)
})
});
function openModal(modal) {
if (modal == null) return
modal.classList.add('active'); // here is html
overlay.classList.add('active');
lfade.classList.add('active')
};
function closeModal(modal) {
if (modal == null) return
modal.classList.remove('active')
overlay.classList.remove('active')
lfade.classList.remove('active')
};
}
load();
mClose();
disModal();