-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
57 lines (51 loc) · 1.81 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
51
52
53
54
55
56
57
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');
}
document.addEventListener('DOMContentLoaded', () => {
const spans = document.querySelectorAll('.cube span');
setInterval(() => {
// Remove existing animation classes
spans.forEach(span => span.classList.remove('animated'));
// Get a random span
const randomSpan = spans[Math.floor(Math.random() * spans.length)];
// Add animation class to the random span
randomSpan.classList.add('animated');
}, 1000); // Change animation every second
});