-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
45 lines (38 loc) · 1.28 KB
/
main.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
// counter design
document.addEventListener("DOMContentLoaded", () => {
function counter(id, start, end, duration) {
let obj = document.getElementById(id),
current = start,
range = end - start,
increment = end > start ? 1 : -1,
step = Math.abs(Math.floor(duration / range)),
timer = setInterval(() => {
current += increment;
obj.textContent = current;
if (current == end) {
clearInterval(timer);
}
}, step);
}
counter("count1", 0, 1287, 3000);
counter("count2", 100, 950, 2500);
counter("count3", 0, 1000, 3000);
counter("count4", 0, 1200, 3000);
});
//ACTIVE NAV BAR
let nav = document.querySelector(".navigation-wrap");
window.onscroll = function () {
if (document.documentElement.scrollTop > 20) {
nav.classList.add("scroll-on");
} else {
nav.classList.remove("scroll-on");
}
}
//nav bar
let navBar = document.querySelectorAll('.nav-link');
let navCollapse = document.querySelector('.navbar-collapse.collapse');
navBar.forEach(function (a) {
a.addEventListener("click", function () {
navCollapse.classList.remove("show");
})
})