Skip to content

Instantly share code, notes, and snippets.

@merapi
Created May 28, 2020 22:28
Show Gist options
  • Select an option

  • Save merapi/39bb0f3feebae61d5dfd479048f1038f to your computer and use it in GitHub Desktop.

Select an option

Save merapi/39bb0f3feebae61d5dfd479048f1038f to your computer and use it in GitHub Desktop.
let clientX = -100;
let clientY = -100;
const innerCursor = document.body.appendChild(document.createElement('div'));
innerCursor.style =
'width:0px; height:0px; border-left: 10px solid red; border-bottom: 10px solid transparent; position:absolute; top:0; left:0; z-index:999; pointer-events:none;';
document.addEventListener('mousemove', (e) => {
clientX = e.clientX;
clientY = e.clientY;
});
const render = () => {
innerCursor.style.transform = `translate(${clientX}px,${clientY}px)`;
requestAnimationFrame(render);
};
requestAnimationFrame(render);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment