I have been trying for hours but can’t seem to get it to work, either my cursor entire disappears or the original cursor is there but only when hovering over clickable boxes… I tried multiple ways, but something keeps on overwriting or clashing with my code. anyone who can help?
I tried to seclude my code entirely from shopify’s codes by making a clean page and purely adding the cursor code in and there it works perfect… (unless you change layout from; none to theme → theme.liquid)
code on the clean page:
{% layout none %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Firefly Cursor Test</title>
<style>
html, body {
margin: 0;
height: 100%;
background: #111;
cursor: none;
overflow: hidden;
}
#cursor {
position: fixed;
width: 10px;
height: 10px;
background: white;
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 9999;
}
.sparkle {
position: fixed;
width: 6px;
height: 6px;
background: rgba(255,255,255,0.8);
border-radius: 50%;
pointer-events: none;
z-index: 9998;
animation: sparkleFloat 1.8s ease-out forwards;
}
@keyframes sparkleFloat {
0% {
transform: translateY(0) scale(1);
opacity: 1;
}
100% {
transform: translateY(-40px) scale(0.3);
opacity: 0;
}
}
</style>
</head>
<body>
<div id="cursor"></div>
<script>
const cursor = document.getElementById("cursor");
let mouseX = window.innerWidth / 2;
let mouseY = window.innerHeight / 2;
document.addEventListener("mousemove", e => {
mouseX = e.clientX;
mouseY = e.clientY;
});
function renderCursor() {
cursor.style.left = mouseX + "px";
cursor.style.top = mouseY + "px";
requestAnimationFrame(renderCursor);
}
renderCursor();
function spawnSparkle() {
const sparkle = document.createElement("div");
sparkle.className = "sparkle";
sparkle.style.left = (mouseX + (Math.random() * 20 - 10)) + "px";
sparkle.style.top = (mouseY + (Math.random() * 20 - 10)) + "px";
document.body.appendChild(sparkle);
setTimeout(() => sparkle.remove(), 1800);
}
function sparkleLoop() {
spawnSparkle();
setTimeout(sparkleLoop, 100 + Math.random() * 100);
}
sparkleLoop();
</script>
</body>
</html>