-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (40 loc) · 1.32 KB
/
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
39
40
41
42
let nextButton = document.getElementById('next');
let prevButton = document.getElementById('prev');
let carousel = document.querySelector('.carousel');
let listHTML = document.querySelector('.carousel .list');
let seeMoreButtons = document.querySelectorAll('.seeMore');
let backButton = document.getElementById('back');
nextButton.onclick = function(){
showSlider('next');
}
prevButton.onclick = function(){
showSlider('prev');
}
let unAcceppClick;
const showSlider = (type) => {
nextButton.style.pointerEvents = 'none';
prevButton.style.pointerEvents = 'none';
carousel.classList.remove('next', 'prev');
let items = document.querySelectorAll('.carousel .list .item');
if(type === 'next'){
listHTML.appendChild(items[0]);
carousel.classList.add('next');
}else{
listHTML.prepend(items[items.length - 1]);
carousel.classList.add('prev');
}
clearTimeout(unAcceppClick);
unAcceppClick = setTimeout(()=>{
nextButton.style.pointerEvents = 'auto';
prevButton.style.pointerEvents = 'auto';
}, 2000)
}
seeMoreButtons.forEach((button) => {
button.onclick = function(){
carousel.classList.remove('next', 'prev');
carousel.classList.add('showDetail');
}
});
backButton.onclick = function(){
carousel.classList.remove('showDetail');
}