-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (40 loc) · 1.29 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
43
44
45
46
47
48
49
50
const nextButton = document.querySelector("#next")
const prevButton = document.querySelector("#prev")
const backButton = document.querySelector("#back")
const seeMoteButtons = document.querySelectorAll(".seeMore")
const carousel = document.querySelector(".carousel")
const listHTML = document.querySelector(".carousel .list")
nextButton.addEventListener("click",()=>{
showSlider('next');
})
prevButton.addEventListener("click",()=>{
showSlider('prev');
})
let unAcceptClick;
const showSlider = (type) =>{
nextButton.style.pointerEvents = 'none'
prevButton.style.pointerEvents = 'none'
let items = document.querySelectorAll(".carousel .list .item");
carousel.classList.remove("next","prev")
if(type==="next"){
listHTML.appendChild(items[0]);
carousel.classList.add("next")
}else{
let positionLast = items.length -1;
listHTML.prepend(items[positionLast])
carousel.classList.add("prev")
}
clearInterval(unAcceptClick)
unAcceptClick = setTimeout(() => {
nextButton.style.pointerEvents = 'auto'
prevButton.style.pointerEvents = 'auto'
}, 2000);
}
seeMoteButtons.forEach((buttons)=>{
buttons.addEventListener("click",()=>{
carousel.classList.add("showDetail")
})
})
backButton.addEventListener("click",()=>{
carousel.classList.remove("showDetail")
})