I am creating a reader web application. I want to hide my mouse cursor after an idle time and it will be showed up when I move the mouse for my webpage using JavaScript, CSS.
What is best way to achieve it?
thanks
I am creating a reader web application. I want to hide my mouse cursor after an idle time and it will be showed up when I move the mouse for my webpage using JavaScript, CSS.
What is best way to achieve it?
thanks
This worked for me (taken from https://gist.github.com/josephwegner/1228975).
Note reference to an html element with id wrapper.
//Requires jQuery - http://code.jquery.com/jquery-1.6.4.min.js
$(document).ready(function() {
var idleMouseTimer;
var forceMouseHide = false;
$("body").css('cursor', 'none');
$("#wrapper").mousemove(function(ev) {
if(!forceMouseHide) {
$("body").css('cursor', '');
clearTimeout(idleMouseTimer);
idleMouseTimer = setTimeout(function() {
$("body").css('cursor', 'none');
forceMouseHide = true;
setTimeout(function() {
forceMouseHide = false;
}, 200);
}, 1000);
}
});
});