-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
234 lines (204 loc) · 6.92 KB
/
script.js
File metadata and controls
234 lines (204 loc) · 6.92 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// Initialize AOS (Animate On Scroll)
AOS.init({
once: true,
offset: 100,
duration: 800,
easing: 'ease-out-cubic',
});
// Initialize Typed.js
const typed = new Typed('#typed-text', {
strings: [
'Programmer',
'FinTech Enthusiast',
'Problem Solver',
'Leader'
],
typeSpeed: 50,
backSpeed: 30,
backDelay: 2000,
loop: true,
smartBackspace: true,
});
// Initialize Particles.js
particlesJS("particles-js", {
"particles": {
"number": {
"value": 60,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": "#00f2ff"
},
"shape": {
"type": "circle",
},
"opacity": {
"value": 0.3,
"random": true,
},
"size": {
"value": 3,
"random": true,
},
"line_linked": {
"enable": true,
"distance": 150,
"color": "#4d4dff",
"opacity": 0.2,
"width": 1
},
"move": {
"enable": true,
"speed": 2,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"bounce": false,
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "grab"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"grab": {
"distance": 140,
"line_linked": {
"opacity": 0.8
}
},
"push": {
"particles_nb": 4
}
}
},
"retina_detect": true
});
// Mobile Menu Logic
const mobileMenuBtn = document.getElementById('mobile-menu-btn');
const closeMenuBtn = document.getElementById('close-menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
const mobileLinks = document.querySelectorAll('.mobile-link');
function toggleMenu() {
mobileMenu.classList.toggle('open');
if (mobileMenu.classList.contains('open')) {
document.body.style.overflow = 'hidden'; // Prevent scrolling when menu is open
} else {
document.body.style.overflow = 'auto';
}
}
mobileMenuBtn.addEventListener('click', toggleMenu);
closeMenuBtn.addEventListener('click', toggleMenu);
mobileLinks.forEach(link => {
link.addEventListener('click', toggleMenu);
});
// Navbar Scroll Effect
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('bg-black/80', 'shadow-lg');
navbar.classList.remove('bg-black/30');
} else {
navbar.classList.remove('bg-black/80', 'shadow-lg');
navbar.classList.add('bg-black/30');
}
});
// GSAP Interactive Effects (Optional simple parallax or hover)
// Example: Parallax on the profile image container
const heroSection = document.getElementById('home');
const profileContainer = document.querySelector('.order-1.md\\:order-2'); // Hexagon container
if (heroSection && profileContainer) {
heroSection.addEventListener('mousemove', (e) => {
const x = (e.clientX - window.innerWidth / 2) * 0.02;
const y = (e.clientY - window.innerHeight / 2) * 0.02;
gsap.to(profileContainer, {
x: x,
y: y,
duration: 1,
ease: "power2.out"
});
});
}
// WhatsApp Contact Logic
const sendBtn = document.getElementById('send-btn');
if (sendBtn) {
sendBtn.addEventListener('click', () => {
const name = document.getElementById('contact-name').value;
const email = document.getElementById('contact-email').value;
const subject = document.getElementById('contact-subject').value;
const message = document.getElementById('contact-message').value;
const phoneNumber = '8801572902196';
// Formatting the message for WhatsApp
// Using encodeURIComponent is better for handling special characters
const formattedMessage = `*Name:* ${name}\n*Email:* ${email}\n*Subject:* ${subject}\n*Message:* ${message}`;
const encodedMessage = encodeURIComponent(formattedMessage);
const whatsappURL = `https://wa.me/${phoneNumber}?text=${encodedMessage}`;
window.open(whatsappURL, '_blank');
});
}
// Auto Update Copyright Year
const yearSpan = document.getElementById('copyright-year');
if (yearSpan) {
yearSpan.textContent = new Date().getFullYear();
}
// ===== CUSTOM CURSOR =====
(function () {
const dot = document.getElementById('cursor-dot');
const glow = document.getElementById('cursor-glow');
if (!dot || !glow) return;
// Skip on touch devices
if (window.matchMedia('(hover: none) and (pointer: coarse)').matches) return;
let mouseX = window.innerWidth / 2;
let mouseY = window.innerHeight / 2;
let glowX = mouseX;
let glowY = mouseY;
// Track mouse position instantly for the dot
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
// Move the small dot instantly (no lag)
dot.style.left = mouseX + 'px';
dot.style.top = mouseY + 'px';
});
// Animate the glow ring with smooth lerp (lag behind)
function animateGlow() {
// Linear interpolation for smooth trailing effect
glowX += (mouseX - glowX) * 0.12;
glowY += (mouseY - glowY) * 0.12;
glow.style.left = glowX + 'px';
glow.style.top = glowY + 'px';
requestAnimationFrame(animateGlow);
}
animateGlow();
// Hover effect on interactive elements
const interactiveSelectors = 'a, button, input, textarea, select, label, [role="button"], .glass-card';
document.querySelectorAll(interactiveSelectors).forEach(el => {
el.addEventListener('mouseenter', () => document.body.classList.add('cursor-hover'));
el.addEventListener('mouseleave', () => document.body.classList.remove('cursor-hover'));
});
// Click effect
document.addEventListener('mousedown', () => document.body.classList.add('cursor-click'));
document.addEventListener('mouseup', () => document.body.classList.remove('cursor-click'));
// Hide when mouse leaves window
document.addEventListener('mouseleave', () => {
dot.style.opacity = '0';
glow.style.opacity = '0';
});
document.addEventListener('mouseenter', () => {
dot.style.opacity = '1';
glow.style.opacity = '1';
});
})();