tags:

views:

57

answers:

2

I know what code to use to make something wait X seconds before fading out...

$('div#extras').delay(800).fadeOut(3000); 

But this is for the ipad, & I would like it to only fade out if the user has not moved or touched anything for about 2 seconds or so.

I can't exactly use onmousemove with this.. Any ideas?

For anyone interested.. What I did was use:

        //If user touches page, show menu
        $('.touch').bind( "touchstart", function(e){
            $('div#extras').stop().fadeTo('fast', 1);
        });
        //If user moves page, show menu
        $('.touch').bind( "touchmove", function(e){
            $('div#extras').stop().fadeTo('fast', 1);
        });
        //If user does not touch or move page, fade menu
        $('.touch').bind( "touchend", function(e){
            $('div#extras').delay(2000).fadeTo(1500, 0);
        });

Thanks for all your help

A: 

you could log the time every time the user touch something, and verify it using setTimeout(). If more than 2 sec, you launch your hiding code.

Sirber
How could I log it? Thanks
Annie
like jAndy's answer :)
Sirber
+3  A: 
(function(){
   var timerId = null;    

   $(document).bind('mousemove mousedown mouseup', function(){
       $('div#extras').show();

       clearTimeout(timerId);

       timerId = setTimeout(function(){
           $('div#extras').fadeOut('slow');
       }, 2000);
   });
}());
jAndy