Make disappear after X seconds, if no movement? Jquery/Ipad
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 o开发者_运维知识库r move page, fade menu
$('.touch').bind( "touchend", function(e){
$('div#extras').delay(2000).fadeTo(1500, 0);
});
Thanks for all your help
(function(){
var timerId = null;
$(document).bind('mousemove mousedown mouseup', function(){
$('div#extras').show();
clearTimeout(timerId);
timerId = setTimeout(function(){
$('div#extras').fadeOut('slow');
}, 2000);
});
}());
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.
精彩评论