-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
32 lines (27 loc) · 809 Bytes
/
script.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
/* JS do galeria.html - desenvolvido por Patrícia Sousa*/
$(document).ready(function () {
let currentIndex = 0;
const totalItems = $('#carousel li').length;
$('#next').click(function (e) {
e.preventDefault();
if (currentIndex < totalItems - 1) {
currentIndex++;
} else {
currentIndex = 0;
}
updateCarousel();
});
$('#prev').click(function (e) {
e.preventDefault();
if (currentIndex > 0) {
currentIndex--;
} else {
currentIndex = totalItems - 1;
}
updateCarousel();
});
function updateCarousel() {
const offset = -currentIndex * 550; // Deslocamento de 550px para o tamanho da imagem
$('#carousel').css('transform', 'translateX(' + offset + 'px)');
}
});