-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (46 loc) · 1.33 KB
/
index.js
File metadata and controls
49 lines (46 loc) · 1.33 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
const prevNav = document.querySelector(".nav.left");
const nextNav = document.querySelector(".nav.right");
const sliders = document.querySelector(".slider");
const cards = document.querySelectorAll(".card");
console.log(cards);
nextNav.addEventListener("click", () => {
// const fCard = cards[0];
// fCard.style.left = "-20px";
// console.log(fCard.style.left);
cards.forEach(function (card) {
if (card.style.left) {
const factor = Number(card.style.left.replace("px", ""));
card.style.left = `${factor - 120}px`;
} else {
card.style.left = "-120px";
}
});
});
prevNav.addEventListener("click", () => {
// const fCard = cards[0];
// fCard.style.left = "-20px";
// console.log(fCard.style.left);
clearInterval(id);
cards.forEach(function (card) {
if (card.style.left) {
const factor = Number(card.style.left.replace("px", ""));
card.style.left = `${factor + 120}px`;
} else {
card.style.left = "120px";
}
});
});
setTimeout(() => {
console.log("printing");
}, 5000);
const id = setInterval(() => {
cards.forEach(function (card) {
if (card.style.left) {
const factor = Number(card.style.left.replace("px", ""));
card.style.left = `${factor - 120}px`;
} else {
card.style.left = "-120px";
}
});
console.log(new Date().toISOString());
}, 5000);