Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Android/PhoneGap应用程序中检测屏幕空闲或活动_Javascript_Android_Jquery_Cordova - Fatal编程技术网

Javascript 在Android/PhoneGap应用程序中检测屏幕空闲或活动

Javascript 在Android/PhoneGap应用程序中检测屏幕空闲或活动,javascript,android,jquery,cordova,Javascript,Android,Jquery,Cordova,我正在使用JQuery 1.4.2和PhoneGap创建一个应用程序。是否有功能或插件可用于检测空闲屏幕或活动屏幕?我想隐藏/显示一些带有功能的导航按钮。任何方向都将不胜感激 我发现了一个不起作用的例子: $('body').bind('touchstart',function() { clearInterval(myTimer); }); $('body').bind('touchend', function() { myTimer = setInterval(functi

我正在使用JQuery 1.4.2和PhoneGap创建一个应用程序。是否有功能或插件可用于检测空闲屏幕或活动屏幕?我想隐藏/显示一些带有功能的导航按钮。任何方向都将不胜感激

我发现了一个不起作用的例子:

$('body').bind('touchstart',function() {
    clearInterval(myTimer);
});

$('body').bind('touchend', function() {
     myTimer = setInterval(function() { 
                          /* return user to homepage */
                        },30000);
});
也尝试过这个,但没有结果:

 $("#eventPage").on("scrollstart",function() {

         $("#preEventBtn").hide();
        $("#nextEventBtn").hide();
});
解决方案:

 $(document).on("scrollstart",function() {

         $("#preEventBtn").show();
        $("#nextEventBtn").show();
});

     $(document).on("scrollstop",function() {

             $("#preEventBtn").fadeOut().delay(5000);
            $("#nextEventBtn").fadeOut().delay(5000);
    });

     $(document).on("tap",function() {

             $("#preEventBtn").show();
            $("#nextEventBtn").show();
    });

这将有助于解决您的滚动问题

var _scrollTimeout = 0;
var $fixedDiv = $("#fixed-div");

$(window).on("scroll", function() {
    clearTimeout(_scrollTimeout);
    $fixedDiv.stop().fadeIn(500);
    _scrollTimeout = setTimeout(function() {
        $fixedDiv.stop().fadeOut(1000);
    }, 500);
});
这显然是一个示例,您需要修改它以满足您的特定需求,但这里有一个工作示例


您能提供一个类似的例子吗?检测触摸和滚动事件就足够了,不是吗?那是相当微不足道的。“到目前为止你都试了些什么?”阿切尔说得好,我把我的问题调整得更具体了。我不能让scrollstart工作(现在有问题的例子),也找不到任何检测空闲屏幕的工作代码。我真的很喜欢这种方法,比我的版本平滑得多。非常感谢。