Last active
December 20, 2021 21:46
-
-
Save kidGodzilla/33ad45808e995a7e3ec714fd83db3017 to your computer and use it in GitHub Desktop.
Hide Idle Cursor until mousemove after 5s delay
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
/** | |
* jQuery | |
*/ | |
$(function () { | |
$(document).mousemove(function () { | |
$('html, body').css({ cursor: 'default' }); | |
clearTimeout(window.__ttimer); | |
window.__ttimer = setTimeout(function () { | |
$('html, body').css({ cursor: 'none' }); | |
}, 5000); | |
}); | |
}); | |
/** | |
* Vanilla | |
*/ | |
document.body.addEventListener('mousemove', e => { | |
document.body.style.cursor = 'default'; | |
clearTimeout(window.__ttimer); | |
window.__ttimer = setTimeout(function () { | |
document.body.style.cursor = 'none'; | |
}, 5000); | |
}); | |
/** | |
* If you enjoy code golf, improve this: | |
*/ | |
// 148 | |
db=document.body;dbs=db.style;db.addEventListener('mousemove',(e,t)=>{dbs.cursor='default';clearTimeout(t);t=setTimeout(e=>dbs.cursor='none',5e3)}); | |
// 129 | |
db=document.body;dbs=db.style;db.onmousemove=(e,t)=>{dbs.cursor='default';clearTimeout(t);t=setTimeout(f=>dbs.cursor='none',5e3)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment