我有下面的代码来检查HTML5中的设备方向和设备运动处理,这是从http://dev.w3.org/geo/api/spec-source-orientation.html获得的。我使用iPhone3G测试了我的代码,运动事件被困住了。我不知道为什么设备方向没有被困住。我相信,由于'compassneedscalibration'没有Compass支持,所以我无法捕获iPhone3G事件。
我在Android浏览器上测试了应用程序。(HTC Wildfire)我什么都不知道。请分享你的原因,为什么我们没有得到的事件在安卓手机?
window.addEventListener("compassneedscalibration", function(event) {
alert('Your compass needs calibrating! Wave your device in a figure-eight motion');
event.preventDefault();
}, true);
window.addEventListener("deviceorientation", function(event) {
// process event.alpha, event.beta and event.gamma
alert("deviceorientation");
}, true);
window.addEventListener("devicemotion", function(event) {
// Process event.acceleration, event.accelerationIncludingGravity,
// event.rotationRate and event.interval
alert("devicemotion");
}, true);更新1
在iPhone和iPad中测试时,我注意到一件事是,设备是否移动,事件会持续触发,不会停止。
更新2
我发现了我在更新1中提出的问题背后的原因。似乎API检测和传送加速度计数据50次每秒50次。
发布于 2011-08-26 05:28:03
我知道现在这些功能只在iOS Safari浏览器中实现。因此,我们不能在iOS中捕获这些事件。
来源:http://www.mobilexweb.com/samples/ball.html
发布于 2011-08-25 17:46:32
尝试监听Android中的“调整大小”事件。如果您使用的是jQuery,代码可能如下所示:
$(window).bind('resize', function() {
alert('resize!');
});发布于 2011-12-07 21:17:07
在iOS上,需要捕获的事件是“面向方面的更改”。
https://stackoverflow.com/questions/7188288
复制相似问题