-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (35 loc) · 1.28 KB
/
script.js
File metadata and controls
41 lines (35 loc) · 1.28 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
const cursor = document.getElementById('cursor');
const ring = document.getElementById('cursorRing');
let mx = 0, my = 0, rx = 0, ry = 0;
document.addEventListener('mousemove', (e) => {
mx = e.clientX;
my = e.clientY;
cursor.style.left = `${mx - 6}px`;
cursor.style.top = `${my - 6}px`;
});
function animateRing() {
rx += (mx - rx - 18) * 0.12;
ry += (my - ry - 18) * 0.12;
ring.style.left = `${rx}px`;
ring.style.top = `${ry}px`;
requestAnimationFrame(animateRing);
}
animateRing();
document.querySelectorAll('button, a').forEach((el) => {
el.addEventListener('mouseenter', () => { cursor.style.transform = 'scale(2.5)'; });
el.addEventListener('mouseleave', () => { cursor.style.transform = 'scale(1)'; });
});
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) entry.target.classList.add('visible');
});
}, { threshold: 0.15 });
document.querySelectorAll('.reveal').forEach((el) => observer.observe(el));
function randomFlicker() {
const pools = document.querySelectorAll('.card-pool');
if (!pools.length) return;
const idx = Math.floor(Math.random() * pools.length);
pools[idx].style.opacity = '0.4';
setTimeout(() => { pools[idx].style.opacity = '1'; }, 100);
}
setInterval(randomFlicker, 3000);