-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
173 lines (147 loc) · 3.44 KB
/
scripts.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const openBtn = document.getElementById('open-icon');
const closeBtn = document.getElementById('close-icon');
const mobileMenu = document.getElementById('mobile-nav');
gsap.registerPlugin(ScrollTrigger);
gsap.from('.a1', {
scrollTrigger: {
trigger: '.a1',
start: "top center",
},
duration: 2,
opacity: 0,
x: -100
})
gsap.from('.a2', {
scrollTrigger: {
trigger: '.a2',
start: "top center",
},
duration: 2,
opacity: 0,
x: -100
})
gsap.from('.a3', {
scrollTrigger: {
trigger: '.a3',
start: "top center",
},
duration: 2,
opacity: 0,
x: -100
})
gsap.from('.anim-2', {
scrollTrigger: {
trigger: '.anim-2',
start: "top center",
},
duration: 0.6,
y: -200,
opacity: 0,
stagger: 0.3
})
gsap.from('.anim-3', {
duration: 1,
opacity: 0,
x: -1000
})
gsap.from('.anim-4', {
duration: 1,
opacity: 0
})
gsap.from('.anim-6', {
scrollTrigger: {
trigger: '.anim-6',
start: "top bottom",
},
duration: 0.6,
y: -200,
opacity: 0,
stagger: 0.3
})
openBtn.addEventListener('click', () => {
const tl = gsap.timeline();
tl.to(mobileMenu, {
duration: 0.5,
right: "0"
})
tl.from(closeBtn, {
duration: 1,
opacity: 0,
stagger: 1
})
});
const closeMenu = () => {
gsap.to(mobileMenu, {
duration: 0.5,
right: "-100%"
});
}
closeBtn.addEventListener('click', () => {
closeMenu();
});
// Scroll anchors
const intro = document.getElementById('intro-tag');
const about = document.getElementById('about-tag');
const services = document.getElementById('services-tag');
const contact = document.getElementById('contact-tag');
const aboutAnchor = document.getElementById('about-anchor');
const servicesAnchor = document.getElementById('services-anchor');
const contactAnchor = document.getElementById('contact-anchor');
const aboutAnchorM = document.getElementById('about-anchor-m');
const servicesAnchorM = document.getElementById('services-anchor-m');
const contactAnchorM = document.getElementById('contact-anchor-m');
const toTop = document.querySelector('.toTop');
if (window.screen.width > 348) {
document.addEventListener('scroll', () => {
if (window.pageYOffset >= 200) {
toTop.style.display = "block";
} else {
toTop.style.display = "none";
}
});
}
toTop.addEventListener('click', (e) => {
e.preventDefault();
intro.scrollIntoView({
behavior: 'smooth'
});
});
aboutAnchor.addEventListener('click', (e) => {
e.preventDefault();
about.scrollIntoView({
behavior: 'smooth'
});
});
servicesAnchor.addEventListener('click', (e) => {
e.preventDefault();
services.scrollIntoView({
behavior: 'smooth'
});
});
contactAnchor.addEventListener('click', (e) => {
e.preventDefault();
contact.scrollIntoView({
behavior: 'smooth'
});
});
aboutAnchorM.addEventListener('click', (e) => {
e.preventDefault();
closeMenu();
about.scrollIntoView({
behavior: 'smooth'
});
});
servicesAnchorM.addEventListener('click', (e) => {
e.preventDefault();
closeMenu();
services.scrollIntoView({
behavior: 'smooth'
});
});
contactAnchorM.addEventListener('click', (e) => {
e.preventDefault();
closeMenu();
contact.scrollIntoView({
behavior: 'smooth'
});
});