I am using this custom cursor in my react project:
Cursor.js
import React from "react";
import "./Cursor.scss";
function Cursor() {
return (
<div>
<h4 class="cursor"></h4>
</div>
);
}
export default Cursor;
Cursor.scss:
@import "/src/Utilities/Varibles.scss";
*{
cursor: none;
}
.cursor {
position: absolute;
width: 40px;
height: 40px;
background: $green;
border-radius: 50%;
top: var(--y, 0);
left: var(--x, 0);
transform: translate(-50%, -100%);
z-index: 2;
mix-blend-mode: difference;
pointer-events: none;
}
and then I import it in my App.js
...
function App() {
document.onmousemove = function(e) {
document.body.style.setProperty('--x',(e.clientX)+'px');
document.body.style.setProperty('--y',(e.clientY)+'px');
}
return (
...
But when I scroll more than the 100% of the viewport height, the cursor doesn't follow my mouse position. I don't really know how to make the cursor keep my mouse position while scrolling to the bottom of the page.
The App.js doesn't have any styles, the styles are on the index.scss:
@import "/src/Utilities/Varibles.scss";
html{
scroll-behavior: smooth;
}
body {
background-color: $blue;
width: 100vw;
height: 100vh;
overflow-x: hidden;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
display: flex;
flex-direction: column;
margin: 0 auto;
&::-webkit-scrollbar {
display: none;
}
}
You can see whta happens here: https://marclopez.oddsolutionslab.com/
Does anyone know how to solve this?