-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (38 loc) · 1.31 KB
/
script.js
File metadata and controls
46 lines (38 loc) · 1.31 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
'use strict';
const slides = document.querySelector('.slides');
const arrowLeft = document.querySelector('.arrow-left');
const arrowRight = document.querySelector('.arrow-right');
const showLeft = () => {
arrowLeft.disabled = true;
slides.lastElementChild.classList.add('thinner');
slides.prepend(slides.lastElementChild);
setTimeout(() => slides.firstElementChild.classList.remove('thinner'));
setTimeout(() => arrowLeft.disabled = false, 700);
};
const showRight = () => {
arrowRight.disabled = true;
slides.firstElementChild.classList.add('thinner');
setTimeout(() => {
slides.append(slides.firstElementChild);
slides.lastElementChild.classList.remove('thinner');
arrowRight.disabled = false;
}, 700);
};
arrowLeft.addEventListener('click', showLeft);
arrowRight.addEventListener('click', showRight);
const burger = document.querySelector('.burger');
const menu = document.querySelector('.menu');
burger.addEventListener('click', () => {
burger.classList.toggle('active');
menu.classList.toggle('active');
});
menu.querySelectorAll('li').forEach(li =>
li.addEventListener('click', () => {
burger.classList.remove('active');
menu.classList.remove('active');
})
);
document.addEventListener('scroll', () => {
burger.classList.remove('active');
menu.classList.remove('active');
});