-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (52 loc) · 1.82 KB
/
Copy pathscript.js
File metadata and controls
70 lines (52 loc) · 1.82 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function atualizarContador() {
const dataLancamento = new Date("2025-07-01T00:00:00");
const agora = new Date();
const diferenca = dataLancamento - agora;
if (diferenca <= 0) {
document.getElementById("contador").innerText = "LANÇADO!";
return;
}
const dias = Math.floor(diferenca / (1000 * 60 * 60 * 24));
const horas = Math.floor((diferenca / (1000 * 60 * 60)) % 24);
const minutos = Math.floor((diferenca / (1000 * 60)) % 60);
const segundos = Math.floor((diferenca / 1000) % 60);
document.getElementById("contador").innerText =
`${dias}d ${horas}h ${minutos}m ${segundos}s`;
}
setInterval(atualizarContador, 1000);
atualizarContador();
const carousel = document.querySelector('.carousel');
const images = document.querySelector('.carousel-images');
const totalImages = images.children.length;
let index = 0;
let interval = null;
function updateCarousel() {
images.style.transform = `translateX(-${index * 100}%)`;
}
function nextImage() {
index = (index + 1) % totalImages;
updateCarousel();
}
function prevImage() {
index = (index - 1 + totalImages) % totalImages;
updateCarousel();
}
function startAutoSlide() {
interval = setInterval(nextImage, 3000);
}
function stopAutoSlide() {
clearInterval(interval);
}
document.querySelector('.next').addEventListener('click', () => {
stopAutoSlide();
nextImage();
startAutoSlide();
});
document.querySelector('.prev').addEventListener('click', () => {
stopAutoSlide();
prevImage();
startAutoSlide();
});
carousel.addEventListener('mouseenter', stopAutoSlide);
carousel.addEventListener('mouseleave', startAutoSlide);
startAutoSlide();