Created
May 11, 2020 11:23
-
-
Save iamchristough/70c5e5f9d683f41eca18181761b7f33f to your computer and use it in GitHub Desktop.
Hide Cursor on idle
This file contains 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
(function() { | |
var mouseTimer = null, cursorVisible = true; | |
function disappearCursor() { | |
mouseTimer = null; | |
document.body.style.cursor = "none"; | |
cursorVisible = false; | |
} | |
document.onmousemove = function() { | |
if (mouseTimer) { | |
window.clearTimeout(mouseTimer); | |
} | |
if (!cursorVisible) { | |
document.body.style.cursor = "default"; | |
cursorVisible = true; | |
} | |
mouseTimer = window.setTimeout(disappearCursor, 5000); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment