Skip to content

Commit

Permalink
Merge pull request #367 from akhulisumit/main
Browse files Browse the repository at this point in the history
Adding trailing cursor in learning page
  • Loading branch information
arushi2610 authored Oct 25, 2024
2 parents 0ae63ca + c133479 commit 751de17
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions learning.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,93 @@
hr{
margin-top: 50px;
}
.circle {
height: 24px;
width: 24px;
border-radius: 50%;
position: fixed;
background-color: black; /* Default color of circles */
pointer-events: none; /* Prevent interaction with circles */
z-index: 9999;
transition: transform 0.1s ease-out;
}
</style>
</head>

<body>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<script>
// Store the mouse coordinates
const coords = { x: 0, y: 0 };

// Select all circles (you can add more circles to HTML as needed)
const circles = document.querySelectorAll(".circle");

// Customize the colors for the circles (optional)
const colors = ["#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d", "#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d", "#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060", "#680060", "#60005f", "#48005f", "#3d005e"];

// Initialize circle positions
circles.forEach((circle, index) => {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length]; // Assign colors
});

// Update mouse coordinates on move
window.addEventListener("mousemove", (e) => {
coords.x = e.clientX;
coords.y = e.clientY;
});

// Animation loop for circles
function animateCircles() {
let x = coords.x;
let y = coords.y;

circles.forEach((circle, index) => {
circle.style.left = `${x - 12}px`; // Offset for center alignment
circle.style.top = `${y - 12}px`;

circle.style.transform = `scale(${(circles.length - index) / circles.length})`; // Shrink effect

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

// Start animation
animateCircles();

</script>
<!-- Navbar Section -->
<nav class="navbar">
<a href="index.html" class="flex"
Expand Down

0 comments on commit 751de17

Please sign in to comment.