-
Notifications
You must be signed in to change notification settings - Fork 33
/
index.html
91 lines (81 loc) · 2.67 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./src/assets/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Affinity</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins&family=Roboto+Slab:[email protected]&display=swap"
rel="stylesheet"
/>
<style>
body {
cursor: none; /* Hide the default cursor */
}
.circle {
position: fixed;
border-radius: 50%;
pointer-events: none;
width: 24px;
height: 24px;
transition: background-color 0.3s ease;
}
</style>
</head>
<body>
<div id="cursor-trail"></div>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<script>
const coords = { x: 0, y: 0 };
const colors = [
"#FF1493", // Deep Pink
"#FF69B4", // Hot Pink
"#FFB6C1", // Light Pink
"#FFC0CB", // Pink
"#DB7093", // Pale Violet Red
"#C71585", // Medium Violet Red
"#FF00FF", // Magenta
"#FF00FF", // Fuchsia
"#FF1493", // Deep Pink (repeated for smoother transition)
];
const cursorTrail = document.getElementById('cursor-trail');
const circleCount = 30;
for (let i = 0; i < circleCount; i++) {
const circle = document.createElement('div');
circle.classList.add('circle');
cursorTrail.appendChild(circle);
}
const circles = document.querySelectorAll(".circle");
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});
window.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;
});
function animateCircles() {
let x = coords.x;
let y = coords.y;
circles.forEach(function (circle, index) {
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
circle.style.opacity = (circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
requestAnimationFrame(animateCircles);
}
animateCircles();
</script>
</body>
</html>