-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
172 lines (140 loc) · 3.91 KB
/
Copy pathscript.js
File metadata and controls
172 lines (140 loc) · 3.91 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
/* ===== Typing Effect ===== */
const textArray = [
"BTech CSE Student",
"Cloud Computing Enthusiast",
"AI & ML Enthusiast"
];
let index = 0;
let charIndex = 0;
const typingElement = document.getElementById("typing-text");
function typeEffect() {
if (charIndex < textArray[index].length) {
typingElement.textContent += textArray[index].charAt(charIndex);
charIndex++;
setTimeout(typeEffect, 80);
} else {
setTimeout(eraseEffect, 1500);
}
}
function eraseEffect() {
if (charIndex > 0) {
typingElement.textContent =
textArray[index].substring(0, charIndex - 1);
charIndex--;
setTimeout(eraseEffect, 50);
} else {
index = (index + 1) % textArray.length;
setTimeout(typeEffect, 500);
}
}
document.addEventListener("DOMContentLoaded", typeEffect);
/* ===== Scroll Reveal ===== */
const reveals = document.querySelectorAll(".reveal");
const revealObserver = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add("active");
}
});
},
{ threshold: 0.2 }
);
reveals.forEach(el => revealObserver.observe(el));
/* ===== Active Navbar Highlight ===== */
const sections = document.querySelectorAll("section[id]");
const navLinks = document.querySelectorAll(".nav-link");
window.addEventListener("scroll", () => {
let current = "";
sections.forEach(section => {
const sectionTop = section.offsetTop - 120;
if (scrollY >= sectionTop) {
current = section.getAttribute("id");
}
});
navLinks.forEach(link => {
link.classList.remove("active");
if (link.dataset.section === current) {
link.classList.add("active");
}
});
});
/* ===== Skill Pill Click Glow ===== */
const skillPills = document.querySelectorAll(".skill-pill");
skillPills.forEach(pill => {
pill.addEventListener("click", () => {
pill.classList.toggle("active");
});
});
/* Tool Pill Click Glow */
document.querySelectorAll(".tool-pill").forEach(pill => {
pill.addEventListener("click", () => {
pill.classList.toggle("active");
});
});
document.addEventListener("mousemove", (e) => {
const glow = document.querySelector(".cursor-glow");
glow.style.left = e.clientX + "px";
glow.style.top = e.clientY + "px";
});
window.addEventListener("scroll", () => {
const scroll =
(window.scrollY /
(document.body.scrollHeight - window.innerHeight)) *
100;
document.querySelector(".scroll-progress").style.width = scroll + "%";
});
/* ================= VORTEX BACKGROUND ================= */
const canvas = document.getElementById("vortex-bg");
const ctx = canvas.getContext("2d");
let w, h;
let particles = [];
let mouse = { x: 0, y: 0 };
function resize() {
w = canvas.width = window.innerWidth;
h = canvas.height = window.innerHeight;
}
window.addEventListener("resize", resize);
resize();
window.addEventListener("mousemove", e => {
mouse.x = e.clientX;
mouse.y = e.clientY;
});
class Particle {
constructor() {
this.reset();
}
reset() {
this.angle = Math.random() * Math.PI * 2;
this.radius = Math.random() * Math.min(w, h) * 0.5;
this.speed = 0.002 + Math.random() * 0.003;
this.size = Math.random() * 1.5 + 0.5;
this.alpha = Math.random() * 0.6 + 0.2;
}
update() {
this.angle += this.speed;
const cx = mouse.x || w / 2;
const cy = mouse.y || h / 2;
const x = cx + Math.cos(this.angle) * this.radius;
const y = cy + Math.sin(this.angle) * this.radius * 0.6;
this.radius *= 0.999;
if (this.radius < 10) this.reset();
ctx.beginPath();
ctx.fillStyle = `rgba(56,189,248,${this.alpha})`;
ctx.arc(x, y, this.size, 0, Math.PI * 2);
ctx.fill();
}
}
function init() {
particles = [];
for (let i = 0; i < 600; i++) {
particles.push(new Particle());
}
}
init();
function animate() {
ctx.clearRect(0, 0, w, h);
particles.forEach(p => p.update());
requestAnimationFrame(animate);
}
animate();