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

[BUG] fix the cursor animation, check description #1194 #1286

Merged
merged 2 commits into from
Nov 10, 2024
Merged
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
4 changes: 4 additions & 0 deletions Blog_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
transition: all 0.2s ease-out;
opacity: 0.6;
}
/* Hide cursor when the 'hidden' class is applied */
.cursor.hidden {
visibility: hidden;
}



Expand Down
99 changes: 67 additions & 32 deletions Faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
z-index: 99999999;
transition: transform 0.1s ease-out;
}
/* Hide cursor when the 'hidden' class is applied */
.cursor.hidden {
visibility: hidden;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -427,48 +431,79 @@ <h5 class="footer-heading">Follow Us</h5>
}
});

// Cursor animation
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");

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

// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});

const colors = [
"#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d",
"#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d",
"#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060",
"#680060", "#60005f", "#48005f", "#3d005e"
];
// Update the coordinates when the mouse moves
document.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;

// Update the position of each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
circle.style.left = coords.x - 12 + "px";
circle.style.top = coords.y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
});
});

window.addEventListener("mousemove", function(e){
coords.x = e.clientX;
coords.y = e.clientY;
});
// Add mouseleave event to hide cursor
document.addEventListener("mouseleave", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

// Add mouseenter event to show cursor
document.addEventListener("mouseenter", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

// Add focus and blur events to hide/show cursor
document.addEventListener("focus", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

function animateCircles() {
let x = coords.x;
let y = coords.y;
document.addEventListener("blur", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

circles.forEach(function (circle, index) {
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
// Animation function to move the circles
function animateCircles() {
let x = coords.x;
let y = coords.y;

const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
circles.forEach(function (circle, index) {
circle.x = x;
circle.y = y;

requestAnimationFrame(animateCircles);
}
// Get the next circle in the sequence
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});

// Repeat the animation
requestAnimationFrame(animateCircles);
}

// Start the animation
animateCircles();

animateCircles();

// Set current year in footer
document.getElementById("year").textContent = new Date().getFullYear();
Expand Down
102 changes: 69 additions & 33 deletions about-us.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
z-index: 99999999;
transition: transform 0.1s ease-out;
}
/* Hide cursor when the 'hidden' class is applied */
.cursor.hidden {
visibility: hidden;
}

header {
background: #fa9cfa;
Expand Down Expand Up @@ -529,48 +533,80 @@ <h5 class="footer-heading">Follow Us</h5>
window.scrollTo({ top: 0, behavior: "smooth" });
});

// Cursor animation
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");

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

// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});

// Update the coordinates when the mouse moves
document.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;

// Update the position of each circle
circles.forEach(function (circle, index) {
circle.style.left = coords.x - 12 + "px";
circle.style.top = coords.y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
});
});

// Add mouseleave event to hide cursor
document.addEventListener("mouseleave", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

// Add mouseenter event to show cursor
document.addEventListener("mouseenter", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

// Add focus and blur events to hide/show cursor
document.addEventListener("focus", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

const colors = [
"#ffb56b", "#fdaf69", "#f89d63", "#f59761", "#ef865e", "#ec805d",
"#e36e5c", "#df685c", "#d5585c", "#d1525c", "#c5415d", "#c03b5d",
"#b22c5e", "#ac265e", "#9c155f", "#950f5f", "#830060", "#7c0060",
"#680060", "#60005f", "#48005f", "#3d005e"
];
document.addEventListener("blur", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

// Animation function to move the circles
function animateCircles() {
let x = coords.x;
let y = coords.y;

circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});
circle.x = x;
circle.y = y;

window.addEventListener("mousemove", function(e){
coords.x = e.clientX;
coords.y = e.clientY;
// Get the next circle in the sequence
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});

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.scale = (circles.length - index) / circles.length;
circle.x = x;
circle.y = y;
// Repeat the animation
requestAnimationFrame(animateCircles);
}

const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});
// Start the animation
animateCircles();

requestAnimationFrame(animateCircles);
}

animateCircles();

</script>
</body>
Expand Down
54 changes: 40 additions & 14 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@
z-index: 99999999;
transition: transform 0.1s ease-out;
}
/* Hide cursor when the 'hidden' class is applied */
.cursor.hidden {
visibility: hidden;
}
</style>
</head>

Expand Down Expand Up @@ -465,55 +469,77 @@ <h3 class="lead">
// Coordinates for the cursor
const coords = { x: 0, y: 0 };
const circles = document.querySelectorAll(".circle");

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

// Assign colors and initial position to each circle
circles.forEach(function (circle, index) {
circle.x = 0;
circle.y = 0;
circle.style.backgroundColor = colors[index % colors.length];
});

// Update the coordinates when the mouse moves
window.addEventListener("mousemove", function (e) {
document.addEventListener("mousemove", function (e) {
coords.x = e.clientX;
coords.y = e.clientY;

// Update the position of each circle
circles.forEach(function (circle, index) {
circle.style.left = coords.x - 12 + "px";
circle.style.top = coords.y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;
});
});


// Add mouseleave event to hide cursor
document.addEventListener("mouseleave", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

// Add mouseenter event to show cursor
document.addEventListener("mouseenter", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

// Add focus and blur events to hide/show cursor
document.addEventListener("focus", () => {
circles.forEach(circle => circle.classList.remove("hidden"));
});

document.addEventListener("blur", () => {
circles.forEach(circle => circle.classList.add("hidden"));
});

// Animation function to move the circles
function animateCircles() {
let x = coords.x;
let y = coords.y;

circles.forEach(function (circle, index) {
// Update the position and scale of each circle
circle.style.left = x - 12 + "px";
circle.style.top = y - 12 + "px";
circle.style.scale = (circles.length - index) / circles.length;

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

// Get the next circle in the sequence
const nextCircle = circles[index + 1] || circles[0];
x += (nextCircle.x - x) * 0.3;
y += (nextCircle.y - y) * 0.3;
});

// Repeat the animation
requestAnimationFrame(animateCircles);
}

// Start the animation
animateCircles();
</script>

</body>

</html>
Loading