-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
154 lines (131 loc) · 4.08 KB
/
app.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//header Scroll
let nav = document.querySelector(".navbar");
window.onscroll = function(){
if(document.documentElement.scrollTop>20){
nav.classList.add("header-scrolled");
}else{
nav.classList.remove("header-scrolled");
}
}
//nav hide
let navBar = document.querySelectorAll(".nav-link");
let navCollapse = document.querySelector(".navbar-collapse.collapse");
navBar.forEach((a)=>{
a.addEventListener("click",()=>{navCollapse.classList.remove(".toggler-icon");
navCollapse.classList.remove("show");
})
})
// Owl Carousel
$(document).ready(function(){
$(".client-slider-section").owlCarousel({
item:4,
loop:true,
nav:false,
autoplay: true,
autoplayTimeout: 1000,
autoplayHoverpause: true,
responsiveClass: true,
stagePadding: 50,
responsive:{
0: {
items:2
},
600: {
items: 3
},
1000:{
items: 6
}
}
});
});
// counters
const counters = document.querySelectorAll(".counters span");
const container = document.querySelector(".counters");
// Variable that track if the counters have been activated
let activated = false;
// add scroll event to the page
window.addEventListener("scroll",()=>{
if(scrollY > container.scrollTop - container.scrollHeight-200 && activated === false){
counters.forEach(counter =>{
counter.innerText = 0;
let count = 0;
function updateCount(){
const target = parseInt(counter.dataset.count);
if(count < target){
count+=5; // to controll the speed of counting
counter.innerText = count;
setTimeout(updateCount,10);
}else{
counter.innerText = target;
}
}
updateCount();
activated = true;
});
} else if(scrollY < container.scrollTop - container.scrollHeight - 500 || scrollY ===0 && activated === true){
counters.forEach(counter =>{
counter.innerText = 0;
});
activated = false;
}
})
// for normal scrolling
const observer = new IntersectionObserver((enteries)=>{
enteries.forEach((entry)=>{
console.log(entry)
if(entry.isIntersecting){
entry.target.classList.add('show');
}else{
entry.target.classList.remove('show')
}
})
})
const hiddenElement = document.querySelectorAll('.hidden');
hiddenElement.forEach((el)=> observer.observe(el))
// for cards scrolling effects
const observer2 = new IntersectionObserver((enteries)=>{
enteries.forEach((entry)=>{
console.log(entry)
if(entry.isIntersecting){
entry.target.classList.add('show2');
}else{
entry.target.classList.remove('show2')
}
})
})
const hiddenElement2 = document.querySelectorAll('.hidden2');
hiddenElement2.forEach((el)=> observer2.observe(el))
// FAQ section
const faqs = document.querySelectorAll(".faqsection");
faqs.forEach(faq => {
const question = faq.querySelector(".question");
const answer = faq.querySelector(".answer");
question.addEventListener("click", () => {
if (faq.classList.contains("active")) {
faq.classList.remove("active");
answer.style.maxHeight = null;
} else {
faqs.forEach(otherFaq => {
if (otherFaq.classList.contains("active")) {
otherFaq.classList.remove("active");
otherFaq.querySelector(".answer").style.maxHeight = null;
}
});
faq.classList.add("active");
answer.style.maxHeight = answer.scrollHeight + "px";
}
});
});
// security
document.onkeydown = e =>{
if(e.key == "F12"){
return false;
}
if(e.ctrlKey && e.key == "u"){
return false;
}
if(e.ctrlKey && e.key == "U"){
return false;
}
}