-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
72 lines (58 loc) · 1.91 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
// Handle slide show functionality
let currentSlide = 0;
function showSlide(index) {
const slides = document.querySelectorAll('.slide');
if (slides.length === 0) {
console.error("No slides found.");
return;
}
if (index >= slides.length) {
currentSlide = 0;
} else if (index < 0) {
currentSlide = slides.length - 1;
} else {
currentSlide = index;
}
const slider = document.querySelector('.slider');
if (slider) {
slider.style.transform = `translateX(-${currentSlide * 100}%)`;
} else {
console.error("Slider element not found.");
}
}
function changeSlide(step) {
showSlide(currentSlide + step);
}
// Initialize the slider
showSlide(currentSlide);
// Function to open a tab with an image
function opentab(imageId) {
const tab = document.getElementById("tab");
const tabImg = document.getElementById("tabImg");
if (tab && tabImg) {
tab.style.display = "block";
tabImg.src = document.getElementById(imageId).src;
} else {
console.error("Tab or tab image element not found.");
}
}
// Handle hamburger menu toggle
const hamburger = document.querySelector('.hamburger');
const overlay = document.querySelector('.overlay');
const body = document.body;
if (hamburger && overlay) {
hamburger.addEventListener('click', () => {
overlay.classList.toggle('active');
body.classList.toggle('no-scroll');
hamburger.classList.toggle('active'); // To handle animation
});
// Close the menu when clicking outside the overlay
overlay.addEventListener('click', (e) => {
if (e.target === overlay) {
overlay.classList.remove('active');
body.classList.remove('no-scroll');
}
});
} else {
console.error("Hamburger or overlay element not found.");
}