-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathindex.html
More file actions
123 lines (103 loc) · 3.03 KB
/
index.html
File metadata and controls
123 lines (103 loc) · 3.03 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/code.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>devconnect</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<style>
.circle-container {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 999999;
}
.cursor-circle {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #ff8c00;
box-shadow: 0 0 15px rgba(255, 140, 0, 0.7);
transform: translate(-50%, -50%);
will-change: transform;
mix-blend-mode: screen;
}
.cursor-circle:first-child {
width: 14px;
height: 14px;
background-color: #ffcc00;
box-shadow: 0 0 20px #ff8c00,
0 0 40px rgba(255, 140, 0, 0.5);
z-index: 2;
}
.cursor-clicking {
transform: translate(-50%, -50%) scale(2.5);
background-color: #ffcc00;
}
.cursor-hovering {
transform: translate(-50%, -50%) scale(1.8);
background-color: #ff9900;
}
</style>
<div class="circle-container" id="cursor-trail"></div>
<script>
(function () {
document.body.style.cursor = 'none';
const container = document.getElementById('cursor-trail');
const coords = { x: 0, y: 0 };
const circles = [];
const COUNT = 16;
for (let i = 0; i < COUNT; i++) {
const c = document.createElement('div');
c.className = 'cursor-circle';
c.style.opacity = (1 - i / COUNT).toString();
container.appendChild(c);
circles.push({ el: c, x: 0, y: 0 });
}
window.addEventListener('mousemove', e => {
coords.x = e.clientX;
coords.y = e.clientY;
});
window.addEventListener('mousedown', () =>
circles.forEach(c =>
c.el.classList.add('cursor-clicking')
)
);
window.addEventListener('mouseup', () =>
circles.forEach(c =>
c.el.classList.remove('cursor-clicking')
)
);
window.addEventListener('mouseover', e => {
const interactive = e.target.closest('a,button');
circles.forEach(c =>
c.el.classList.toggle(
'cursor-hovering',
!!interactive
)
);
});
function animate() {
let x = coords.x;
let y = coords.y;
circles.forEach((c, i) => {
c.el.style.left = x + 'px';
c.el.style.top = y + 'px';
c.x = x;
c.y = y;
const next = circles[i + 1] || circles[0];
x += (next.x - x) * 0.4;
y += (next.y - y) * 0.4;
});
requestAnimationFrame(animate);
}
animate();
})();
</script>
</body>
</html>