Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️FIX : Missing mouse animation added on Profile page #1112

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions testp.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ body {

}

.circle {
height: 24px;
width: 24px;
border-radius: 24px;
background-color: black;
position: fixed;
top: 0;
left: 0;
pointer-events: none;
z-index: 99999999;
}

.profile-container {

max-width: 1200px;
Expand Down
24 changes: 24 additions & 0 deletions testp.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@

<div class="profile-container">

<!-- cursor -->
<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>
<!-- cursor ends -->

<div class="content-section">
<h2>Your Profile</h2>
<a href="index.html">
Expand Down
47 changes: 45 additions & 2 deletions testp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,53 @@ const getCurrentTimestamp = () => {
const displayLastActive = () => {
const lastActive = getLastActive();
const formattedTime = new Date(parseInt(lastActive)).toLocaleString();
document.getElementById('last-active').innerHTML = Last active: ${formattedTime};
document.getElementById('last-active').innerHTML = `Last active: ${formattedTime}`;
};

displayLastActive();

//cursor


const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");

const colors = [
"#BCE954", "#98FF98", "#9CB071", "#90C209", "#B2C248",
"#85BB65", "#99C68E", "#6CBB3C", "#3ea055", "#41a317",
"#4AA02C", "#6AA121", "#347C2C", "#387C44", "#437C17",
"#306754", "#254117", "#667C26", "#728C00", "#008000"
];

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"; // Center the circle on the mouse
circle.style.top = y - 12 + "px"; // Center the circle on the mouse

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

circle.x = x;
circle.y = y;

const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.6;
});

requestAnimationFrame(animateCircles);
}

animateCircles();
Loading