Dan001
Coder
Hello
I have a JS & CSS code. I am not a developer at all . I don't know what I have to change in the code to achieve the desired effect
My question is How can I hide the hand cursor when hovering a link?
Below the CSS et JS CODE
Thank you for your help
CSS CODE
--------------
<style>
body {
cursor: none;
min-height: 100%;
background: rgb(0, 0, 0);
}
#myCustomCursor {
position: fixed;
width: 30px;
height: 30px;
background: #000000;
border-radius: 50%;
top: var(--y, 0);
left: var(--x, 0);
transform: translate(-50%, -50%);
mix-blend-mode: normal;
pointer-events: none;
transition-duration: 50ms;
transition-timing-function: ease-out;
z-index: 999999!important;
}
#myCustomCursor.myCursorHoverState {
cursor: none;
width: 90px;
height: 90px;
background: pink;
}
}
</style>
JS CODE
------------
<script>
function createCustomCursor() {
let cursor = document.getElementById('myCustomCursor');
if (cursor) {
console.log('myCustomCursor already exist');
addCursorSpecialEffectToAllPageLinks(cursor);
} else {
cursor = document.createElement("div");
cursor.setAttribute("id", "myCustomCursor");
document.body.appendChild(cursor);
initCustomCursor(cursor);
addCursorSpecialEffectToAllPageLinks(cursor);
}
}
function initCustomCursor(cursor) {
document.body.onmousemove = function(e) {
cursor.style.setProperty('--x', (e.clientX) + 'px');
cursor.style.setProperty('--y', (e.clientY) + 'px');
}
}
function addCursorSpecialEffectToAllPageLinks(cursor) {
var links = document.querySelectorAll("a"); // Get page links
// This ״for loop״ is used to find all the page links and add the "myCursorHoverState" css class to create special effect on hover
for (var i = 0; i < links.length; i++) {
links.addEventListener("mouseenter", function(event) {
console.log('In');
cursor.classList.add("myCursorHoverState"); // Add the hover class
}, false);
links.addEventListener("mouseleave", function(event) {
console.log('Out');
cursor.classList.remove("myCursorHoverState"); // Removethe hover class
}, false);
}
}
function myFunction(x) {
if (x.matches) { // If media query matches
createCustomCursor();
}
}
var x = window.matchMedia("(min-width: 1001px)") //desktop
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes
</script>
I have a JS & CSS code. I am not a developer at all . I don't know what I have to change in the code to achieve the desired effect
My question is How can I hide the hand cursor when hovering a link?
Below the CSS et JS CODE
Thank you for your help
CSS CODE
--------------
<style>
body {
cursor: none;
min-height: 100%;
background: rgb(0, 0, 0);
}
#myCustomCursor {
position: fixed;
width: 30px;
height: 30px;
background: #000000;
border-radius: 50%;
top: var(--y, 0);
left: var(--x, 0);
transform: translate(-50%, -50%);
mix-blend-mode: normal;
pointer-events: none;
transition-duration: 50ms;
transition-timing-function: ease-out;
z-index: 999999!important;
}
#myCustomCursor.myCursorHoverState {
cursor: none;
width: 90px;
height: 90px;
background: pink;
}
}
</style>
JS CODE
------------
<script>
function createCustomCursor() {
let cursor = document.getElementById('myCustomCursor');
if (cursor) {
console.log('myCustomCursor already exist');
addCursorSpecialEffectToAllPageLinks(cursor);
} else {
cursor = document.createElement("div");
cursor.setAttribute("id", "myCustomCursor");
document.body.appendChild(cursor);
initCustomCursor(cursor);
addCursorSpecialEffectToAllPageLinks(cursor);
}
}
function initCustomCursor(cursor) {
document.body.onmousemove = function(e) {
cursor.style.setProperty('--x', (e.clientX) + 'px');
cursor.style.setProperty('--y', (e.clientY) + 'px');
}
}
function addCursorSpecialEffectToAllPageLinks(cursor) {
var links = document.querySelectorAll("a"); // Get page links
// This ״for loop״ is used to find all the page links and add the "myCursorHoverState" css class to create special effect on hover
for (var i = 0; i < links.length; i++) {
links.addEventListener("mouseenter", function(event) {
console.log('In');
cursor.classList.add("myCursorHoverState"); // Add the hover class
}, false);
links.addEventListener("mouseleave", function(event) {
console.log('Out');
cursor.classList.remove("myCursorHoverState"); // Removethe hover class
}, false);
}
}
function myFunction(x) {
if (x.matches) { // If media query matches
createCustomCursor();
}
}
var x = window.matchMedia("(min-width: 1001px)") //desktop
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes
</script>