Skip to content

Instantly share code, notes, and snippets.

@iamchristough
Created May 11, 2020 11:23
Show Gist options
  • Save iamchristough/70c5e5f9d683f41eca18181761b7f33f to your computer and use it in GitHub Desktop.
Save iamchristough/70c5e5f9d683f41eca18181761b7f33f to your computer and use it in GitHub Desktop.
Hide Cursor on idle
(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