-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
141 lines (119 loc) · 3.45 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
const menu = document.querySelector('#mobile-menu');
const menuLinks = document.querySelector('.navbar__menu');
const navbar = document.querySelector('.navbar');
const navLogo = document.querySelector('#navbar__logo');
const body = document.querySelector('body');
const mobileMenu = () => {
menu.classList.toggle('is-active');
menuLinks.classList.toggle('active');
body.classList.toggle('active');
}
menu.addEventListener('click', mobileMenu);
const changeNavbar = () => {
let scrollPos = window.scrollY;
scrollPos >= 80 ? navbar.classList.add('active') : navbar.classList.remove('active');
}
window.addEventListener('scroll', changeNavbar);
const highlightMenu = () => {
const elem = document.querySelector('.highlight');
const homeMenu = document.querySelector('#home-page');
const servicesMenu = document.querySelector('#services-page');
const plansMenu = document.querySelector('#plans-page');
const modalitysMenu = document.querySelector('#modality-page');
let scrollPos = window.scrollY;
console.log(scrollPos);
if (window.innerWidth > 960 && scrollPos < 720) {
homeMenu.classList.add('highlight');
servicesMenu.classList.remove('highlight');
return;
} else if (window.innerWidth > 960 && scrollPos < 1520) {
servicesMenu.classList.add('highlight');
homeMenu.classList.remove('highlight');
plansMenu.classList.remove('highlight');
return;
} else if (window.innerWidth > 960 && scrollPos < 2320) {
plansMenu.classList.add('highlight');
servicesMenu.classList.remove('highlight');
modalitysMenu.classList.remove('highlight');
return;
} else if (window.innerWidth > 960 && scrollPos < 3020) {
modalitysMenu.classList.add('highlight');
plansMenu.classList.remove('highlight');
return;
} else {
modalitysMenu.classList.remove('highlight');
}
if ((elem && window.innerWIdth < 960) || elem) {
elem.classList.remove('highlight');
}
}
window.addEventListener('scroll', highlightMenu);
window.addEventListener('click', highlightMenu);
const hideMobileMenu = () => {
const menuBars = document.querySelector('.is-active');
if (window.innerWidth <= 768 && menuBars) {
menu.classList.toggle('is-active');
menuLinks.classList.remove('active');
}
};
menuLinks.addEventListener('click', hideMobileMenu);
navLogo.addEventListener('click', hideMobileMenu);
//Animations
gsap.registerPlugin(ScrollTrigger);
gsap.from('.animate-hero', {
duration: 0.6,
opacity: 0,
y: -150,
stagger: 0.3,
});
gsap.from('.animate-services', {
scrollTrigger: '.animate-services',
duration: 0.6,
opacity: 0,
y: -150,
stagger: 0.1,
});
gsap.from('.animate-services-img', {
scrollTrigger: '.animate-services',
duration: 1.2,
opacity: 0,
x: -200,
});
gsap.from('.animate-memberships', {
scrollTrigger: '.animate-memberships',
duration: 0.5,
opacity: 0,
y: -150,
stagger: 0.3,
delay: 0.5,
});
gsap.from('.animate-memberships-card', {
scrollTrigger: '.animate-memberships-card',
duration: 1,
opacity: 0,
y: -150,
stagger: 0.1,
delay: 0.2,
});
gsap.from('.animate-modality', {
scrollTrigger: '.animate-modality',
scrollTrigger: '.animate-services',
duration: 0.6,
opacity: 0,
y: -150,
stagger: 0.1
});
gsap.from('.animate-modality-img', {
scrollTrigger: '.animate-modality',
duration: 1.2,
opacity: 0,
x: -100,
});
gsap.from('.animate-email', {
scrollTrigger: '.animate-email',
duration: 0.8,
opacity: 0,
y: -150,
stagger: 0.25,
delay: 0.5,
});