-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
40 lines (40 loc) · 1.23 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
// script.ts
// TypeScript code for handling the hamburger button click
var hamburgerButton = document.getElementById('hamburger');
var mobileLinks = document.getElementById('mobile-links');
if (hamburgerButton && mobileLinks) {
hamburgerButton.addEventListener('click', function () {
mobileLinks.classList.toggle('hidden');
});
}
var currentSlideID = 1;
var sliderElement = document.getElementById('slider');
var totalSlides = sliderElement ? sliderElement.childElementCount : 0;
function next() {
if (currentSlideID < totalSlides) {
currentSlideID++;
showSlide();
}
}
function prev() {
if (currentSlideID > 1) {
currentSlideID--;
showSlide();
}
}
function showSlide() {
var slides = sliderElement === null || sliderElement === void 0 ? void 0 : sliderElement.getElementsByTagName('li');
if (slides) {
for (var index = 0; index < totalSlides; index++) {
var element = slides[index];
if (element) {
if (currentSlideID === index + 1) {
element.classList.remove('hidden');
}
else {
element.classList.add('hidden');
}
}
}
}
}