wykonaj Jquery, gdy mysz przestanie się poruszać
Mam szybki skrypt, który ma ślad podążający za kursorem:
jQuery(document).ready(function(){
$(document).mousemove(function(e){
$('.fall').each(function(){
if ($(this).css("opacity") == 0){
$(this).remove();
};
});
t = (e.pageY - 10).toString() + 'px';
l = (e.pageX - 10).toString() + 'px';
$('.fall').css("margin_left",l);
$('.fall').css("margin_top",t);
var doit = '<div class="fall" style="position:fixed;margin-left:' + l + ';margin-top:' + t + ';">+</div>'
$('body').prepend(doit);
$('#status2').html(e.pageX +', '+ e.pageY);
$('.fall').animate({
marginTop: '+=50px',
opacity: 0
},1000);
});
});
Teraz chciałbym usunąćanimate
część i mieć coś takiego jak poniżej, gdy mysz się nie porusza:
$('.fall').each(function(){
$(this).fadeOut('slow');
$(this).remove()
});
Po prostu nie wiem, jak to zrobić, gdy mysz nie porusza się dłużej niż sekundę. Jakieś pomysły?
Dzięki ioto jsfiddle