forked from PixelKata/project1_Wild_eat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (23 loc) · 967 Bytes
/
index.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
document.addEventListener('DOMContentLoaded', () => {
const burgerButton = document.querySelector('.burger_button');
const navbarMenu = document.querySelector('.navbar_menu');
burgerButton.addEventListener('click', () => {
navbarMenu.classList.toggle('open');
});
});
function next() {
const widthSlider = document.querySelector('.slider').offsetWidth;
const sliderContent = document.querySelector('.slider__content');
sliderContent.scrollLeft += widthSlider;
if (sliderContent.scrollLeft >= sliderContent.scrollWidth - widthSlider) {
sliderContent.scrollLeft = 0;
}
}
function previous() {
const widthSlider = document.querySelector('.slider').offsetWidth;
document.querySelector('.slider__content').scrollLeft -= widthSlider;
sliderContent.scrollLeft -= widthSlider;
if (sliderContent.scrollLeft <= 0) {
sliderContent.scrollLeft = sliderContent.scrollWidth - widthSlider;
}
}