Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MastanSayyad committed Jul 7, 2024
1 parent 8028b98 commit 556a665
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
40 changes: 39 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,45 @@
<div class="circle"></div>
<div class="circle"></div>
</div>
<script src="trail.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");

circles.forEach(function (circle) {
circle.x = 0;
circle.y = 0;
});

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})`;

const nextCircle = circles[index + 1] || circles[0];
circle.x = x;
circle.y = y;

x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});

requestAnimationFrame(animateCircles);
}

animateCircles();
});

</script>
</body>


Expand Down
1 change: 0 additions & 1 deletion src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
body {
background-color: var(--bg-color);
color: var(--text-color);
cursor: none;
}

.navbar {
Expand Down
36 changes: 0 additions & 36 deletions trail.js

This file was deleted.

0 comments on commit 556a665

Please sign in to comment.