-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
119 lines (95 loc) · 3.26 KB
/
script.js
File metadata and controls
119 lines (95 loc) · 3.26 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
const navLinks = document.querySelectorAll('header nav a');
const logoLink = document.querySelector('.logo');
const sections = document.querySelectorAll('section');
const menuIcon = document.querySelector('#menu-icon');
const navbar = document.querySelector('header nav');
menuIcon.addEventListener('click', () => {
menuIcon.classList.toggle('bx-x');
navbar.classList.toggle('active');
});
const activePage = () => {
const header = document.querySelector('header');
const barsBox = document.querySelector('.bars-box');
header.classList.remove('active');
setTimeout(() => {
header.classList.add('active');
}, 1100);
navLinks.forEach(link => {
link.classList.remove('active');
});
barsBox.classList.remove('active');
setTimeout(() => {
barsBox.classList.add('active');
}, 1100);
sections.forEach(section => {
section.classList.remove('active');
});
menuIcon.classList.remove('bx-x');
navbar.classList.remove('active');
};
navLinks.forEach((link, idx) => {
link.addEventListener('click', () => {
if (!link.classList.contains('active')) {
activePage();
link.classList.add('active');
setTimeout(() => {
sections[idx].classList.add('active');
}, 1100);
}
});
});
logoLink.addEventListener('click', () => {
if (!navLinks[0].classList.contains('active')) {
activePage();
navLinks[0].classList.add('active');
setTimeout(() => {
sections[0].classList.add('active');
}, 1100);
}
});
const aboutBtns = document.querySelectorAll('.about-btn');
aboutBtns.forEach((btn, idx) => {
btn.addEventListener('click', () => {
const aboutDetails = document.querySelectorAll('.about-detail');
aboutBtns.forEach(btn => {
btn.classList.remove('active');
});
btn.classList.add('active');
aboutDetails.forEach(detail => {
detail.classList.remove('active');
});
aboutDetails[idx].classList.add('active');
});
});
const arrowRight = document.querySelector('.portfolio-box .navigation .arrow-right');
const arrowLeft = document.querySelector('.portfolio-box .navigation .arrow-left');
let index = 0;
const activePortfolio = () => {
const imgSlide = document.querySelector('.portfolio-carousel .img-slide');
const portfolioDetails = document.querySelectorAll('.portfolio-detail');
imgSlide.style.transform = `translateX(calc(${index * -100}% - ${index * 2}rem))`;
portfolioDetails.forEach(detail => {
detail.classList.remove('active');
});
portfolioDetails[index].classList.add('active');
};
arrowRight.addEventListener('click', () => {
if (index < 4) {
index++;
arrowLeft.classList.remove('disabled');
} else {
index = 5;
arrowRight.classList.add('disabled');
}
activePortfolio();
});
arrowLeft.addEventListener('click', () => {
if (index > 1) {
index--;
arrowRight.classList.remove('disabled');
} else {
index = 0;
arrowLeft.classList.add('disabled');
}
activePortfolio();
});