forked from SUGAM-ARORA/UniCollab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (65 loc) · 1.58 KB
/
index.js
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
import React from 'react';
import { createRoot } from 'react-dom/client'; // Step 1
import './index.css';
import reportWebVitals from './reportWebVitals';
import Preloader from './Components/Preloader';
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
const colors = [
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#3fbcc0c6",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#3fbcc0c6",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
"#ff21bc",
];
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.pageX;
coords.y = e.pageY - window.scrollY; // Adjust for vertical scroll position
});
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.transform = `scale(${(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();
// Updated rendering method
const root = createRoot(document.getElementById('root')); // Step 2
root.render(
<React.StrictMode>
<Preloader />
</React.StrictMode>
);
reportWebVitals();