-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (53 loc) · 1.59 KB
/
script.js
File metadata and controls
63 lines (53 loc) · 1.59 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
51
52
53
54
55
56
57
58
59
60
61
62
class MobileNavbar {
constructor(mobileMenu, navList, navLinks) {
this.mobileMenu = document.querySelector(mobileMenu);
this.navList = document.querySelector(navList);
this.navLinks = document.querySelectorAll(navLinks);
this.activeClass = "active";
this.handleClick = this.handleClick.bind(this);
}
animateLinks() {
this.navLinks.forEach((link, index) => {
link.style.animation
? (link.style.animation = "")
: (link.style.animation = `navLinkFade 0.5s ease forwards ${
index / 7 + 0.3
}s`);
});
}
handleClick() {
this.navList.classList.toggle(this.activeClass);
this.mobileMenu.classList.toggle(this.activeClass);
this.animateLinks();
}
addClickEvent() {
this.mobileMenu.addEventListener("click", this.handleClick);
}
init() {
if (this.mobileMenu) {
this.addClickEvent();
}
return this;
}
}
const mobileNavbar = new MobileNavbar(
".mobile-menu",
".nav-list",
".nav-list li",
);
mobileNavbar.init();
/*
MENU
*/
let menuToggle = document.querySelector('.menuToggle');
let navigation = document.querySelector('.navigation');
menuToggle.onclick = function(){
navigation.classList.toggle('active')
}
/*HOME*/
var headerBg = document.getElementById('home')
window.addEventListener('scroll', function(){
headerBg.style.opacity = 1 +window.pageXOffset/550+'';
headerBg.style.top = +window.pageXOffset+'px';
headerBg.style.backgroundPositionY = - +window.pageXOffset/2+'px';
});