-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
56 lines (46 loc) · 1.96 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// --------------------------------------------------------------------------------------------------
// -> Opening and Closing of drawer in small screens
// --------------------------------------------------------------------------------------------------
const openNav = () => {
document.getElementById("sidenav").style.width = "200px";
};
const closeNav = () => {
document.getElementById("sidenav").style.width = "0";
};
// --------------------------------------------------------------------------------------------------
// -> Incrementing the counter when reach to the achievements section
// --------------------------------------------------------------------------------------------------
const counters = document.querySelectorAll(".counter");
const speed = 200;
const scrollEvent = () => {
if (window.scrollY >= 1700) {
counters.forEach((counter) => {
const updateCount = () => {
const target = +counter.getAttribute("data-target");
const count = +counter.innerText;
const increment = target / speed;
if (count < target) {
counter.innerText = Math.ceil(count + increment);
setTimeout(updateCount, 1);
} else {
count.innerText = target;
}
};
updateCount();
});
}
};
// --------------------------------------------------------------------------------------------------
// -> Sliding the card in testimonials section by pressing circular-buttons
// --------------------------------------------------------------------------------------------------
const wrapper = document.querySelector(".testimonial-wrapper");
const indicators = [...document.querySelectorAll(".indicators button")];
let currentTestimonial = 0;
indicators.forEach((item, i) => {
item.addEventListener("click", () => {
indicators[currentTestimonial].classList.remove("active-btn");
wrapper.style.marginLeft = `-${100 * i}%`;
item.classList.add("active-btn");
currentTestimonial = i;
});
});