-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (32 loc) · 975 Bytes
/
app.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
let burger = document.querySelector(".burger");
let navbar = document.querySelector(".nav");
let resp = document.querySelector(".resp");
console.log(resp);
burger.addEventListener('click', () => {
navbar.classList.toggle('h-nav');
resp.classList.toggle('v-class');
})
const slides = document.querySelectorAll('.slide');
const auto = true; // Auto scroll
const intervalTime = 5000;
let slideInterval;
const nextSlide = () => {
// Get current class
const current = document.querySelector('.current');
// Remove current class
current.classList.remove('current');
// Check for next slide
if (current.nextElementSibling) {
// Add current to next sibling
current.nextElementSibling.classList.add('current');
} else {
// Add current to start
slides[0].classList.add('current');
}
setTimeout(() => current.classList.remove('current'));
};
// Auto slide
if (auto) {
// Run next slide at interval time
slideInterval = setInterval(nextSlide, intervalTime);
}