-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (19 loc) · 772 Bytes
/
index.js
File metadata and controls
24 lines (19 loc) · 772 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
// pegar os elementos do DOM.
const sliderItems = document.querySelector(".slider-items");
const sliderImages = document.querySelectorAll(".slider-items img");
const sliderButtons = document.querySelectorAll(".slider-buttons button");
let counter = 0;
// função para mudar de imagens.
const change = (index = 1, heightSize = sliderItems.clientHeight) =>
(sliderItems.style.transform = `translateY(${-heightSize * index}px)`);
// adicionamos os eventos.
sliderButtons.forEach((_button, index) => {
_button.addEventListener("click", () =>
change(index, sliderItems.clientHeight)
);
});
// const finish = () => counter == sliderButtons.length;
// setInterval(
// () => change(finish() ? (counter = 0) : counter++, sliderItems.clientHeight),
// 1000
// );