-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (21 loc) · 881 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (21 loc) · 881 Bytes
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
let currentPanel = 1;
const panelWidth = 1100; // Largura de cada painel
const totalPanels = 4; // Número total de painéis
function changePanel(direction) {
currentPanel += direction;
if (currentPanel < 1) {
currentPanel = totalPanels;
} else if (currentPanel > totalPanels) {
currentPanel = 1;
}
updateCarousel();
}
function updateCarousel() {
const carousel = document.getElementById('carousel');
const panelContainer = document.querySelector('.carousel-container');
const translateValue = -panelWidth * (currentPanel - 1);
carousel.style.transform = `translateX(${translateValue}px)`;
panelContainer.style.width = `${panelWidth}px`; // Ajuste a largura do contêiner para mostrar apenas um painel
}
// Chame a função updateCarousel inicialmente para garantir que o carrossel inicie corretamente
updateCarousel();