Created
May 28, 2020 22:28
-
-
Save merapi/39bb0f3feebae61d5dfd479048f1038f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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