[英]Detect Screen idle or activity in Android/PhoneGap app
I am using JQuery 1.4.2 along with PhoneGap to create an app. 我正在使用JQuery 1.4.2和PhoneGap来创建应用程序。 Is there a function or plugin available to detect an idle screen or active screen?
是否有可用的功能或插件来检测待机屏幕或活动屏幕? I want to hide/show some navigation buttons with a function.
我想隐藏/显示一些具有功能的导航按钮。 Any direction would be really appreciated.
任何方向将不胜感激。
An example I have found, which did not work: 我发现一个示例,但没有用:
$('body').bind('touchstart',function() {
clearInterval(myTimer);
});
$('body').bind('touchend', function() {
myTimer = setInterval(function() {
/* return user to homepage */
},30000);
});
and tried this as well, with no results: 并尝试了此操作,但没有结果:
$("#eventPage").on("scrollstart",function() {
$("#preEventBtn").hide();
$("#nextEventBtn").hide();
});
Solution: 解:
$(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();
});
This will help with your scrolling issue... 这将有助于解决滚动问题...
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);
});
It's obviously an example and you'll need to modify it to suit your specific needs, but here's a working example... 显然这是一个示例,您需要对其进行修改以适合您的特定需求,但这是一个有效的示例...
http://jsfiddle.net/ArchersFiddle/tK2mY/2/ http://jsfiddle.net/ArchersFiddle/tK2mY/2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.