繁体   English   中英

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

[英]Detect Screen idle or activity in Android/PhoneGap app

我正在使用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);
});

显然这是一个示例,您需要对其进行修改以适合您的特定需求,但这是一个有效的示例...

http://jsfiddle.net/ArchersFiddle/tK2mY/2/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM