<div class="cursor"></div>
<div class="cursor-inner"></div>
* {
cursor: none;
}
.cursor {
position: fixed;
left: 0;
top: 0;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
border: 2px solid #000;
/*transition: transform 0.1s ease-out;*/
transition: transform 0.1s cubic-bezier(0, 0.5, 1, 1);
}
.cursor-inner {
position: fixed;
top: 22px;
left: 22px;
width: 10px;
height: 10px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: black;
pointer-events: none;
}
var cursor = document.querySelector(".cursor");
var cursorInner = document.querySelector(".cursor-inner");
var timeout;
window.addEventListener(
"mousemove",
function (e) {
var x = e.clientX;
var y = e.clientY;
cursorInner.style.transform = `translate3d(${x - 22}px, ${y - 22}px, 0)`;
if (!timeout) {
timeout = setTimeout(function () {
timeout = null;
cursor.style.transform = `translate3d(${x - 22}px, ${y - 22}px, 0)`;
}, 20); //was 50
}
},
false
);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.