I have a quick script that has a trail follow the cursor:
jQuery(document).ready(function(){
$(document).mousemove(function(e){
$(\'.fall\').each(funct
You add a timeout that fires after one second of inactivity, and clear the timeout if the mouse moves within 1 second etc :
var timer;
$(document).on('mousemove', function(e){
clearTimeout(timer);
timer = setTimeout(function() {
$('.fall').fadeOut('slow', function() {
$(this).remove();
});
}, 1000);
});
FIDDLE
EDIT:
Here's how I'd do it
FIDDLE
is this what you require? jsFiddle
lastTimeMouseMoved = new Date().getTime();
var t = setTimeout(function() {
var currentTime = new Date().getTime();
if (currentTime - lastTimeMouseMoved > 1000) {
$('.fall').fadeOut('slow');
// $('.fall').remove();
}
}, 1000)