-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcareers.js
70 lines (51 loc) · 1.78 KB
/
careers.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
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
// carousel
const prevButton = document.querySelector("button#previous-button");
const nextButton = document.querySelector("button#next-button");
const list = document.querySelector(".item-list");
let activeSlideIndex = 0;
const allLis = [...document.querySelectorAll(".item-list li")]
prevButton.addEventListener("click", toPrev);
nextButton.addEventListener("click", toNext);
updateButtons()
// vorige button
function toPrev() {
const currentLi = document.querySelector(".active");
const prevLi = currentLi.previousElementSibling;
currentLi.classList.remove("active");
prevLi.classList.add("active");
activeSlideIndex = allLis.indexOf(prevLi);
const currentTx = parseInt( getComputedStyle(list).getPropertyValue("--tx") );
const newTx = currentTx - 32;
list.style.setProperty("--tx", newTx);
updateButtons();
}
// volgende button
function toNext() {
const currentLi = document.querySelector(".active");
const nextLi = currentLi.nextElementSibling;
currentLi.classList.remove("active");
nextLi.classList.add("active");
activeSlideIndex = allLis.indexOf(nextLi);
const currentTx = parseInt( getComputedStyle(list).getPropertyValue("--tx") );
const newTx = currentTx + 32;
list.style.setProperty("--tx", newTx);
updateButtons();
}
// arrows carousel
function updateButtons() {
const currentTx = parseInt(getComputedStyle(list).getPropertyValue("--tx"));
const listWidth = list.clientWidth;
const listScrollWidth = list.scrollWidth;
// begin geen button
if (activeSlideIndex == 0) {
prevButton.disabled = true;
} else {
prevButton.disabled = false;
}
console.log(activeSlideIndex, allLis.length - 1);
if (activeSlideIndex == allLis.length - 1) {
nextButton.disabled = true;
} else {
nextButton.disabled = false;
}
}