在html5手机中检测摇晃 [英] Detecting shaking in html5 mobile

查看:106
本文介绍了在html5手机中检测摇晃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个html5中的网络应用程序,此时需要能够检测用户何时摇动手机以及它们晃动的速度。我一直在浏览,但似乎无法找到任何我如何实现这一点的例子。我知道html5有一个可以检测手机方向的加速度计,但是它如何检测用户摇动它的速度?

I'm building a web app in html5 at the moment that needs to be able to detect when the user shakes their phone and how fast they are shaking it. I've been browsing around but can't seem to find any examples of how I could implement this. I know html5 has an accelerometer that can detect the orientation of the phone, but how does it detect the speed at which the user is shaking it?

我也正在测试这在我的iPhone上,虽然理想情况下我也希望它能在Android设备上运行。思考?例子也很棒。谢谢!

Also I'm testing this on my iPhone, although ideally I would like it to work on Android devices too. Thoughts? Examples would be great too. Thanks!

推荐答案

你可以使用这个 jQuery插件

你还可以阅读这个... < a href =http://www.html5rocks.com/en/tutorials/device/orientation/ =nofollow> http://www.html5rocks.com/en/tutorials/device/orientation/

And you can also read this... http://www.html5rocks.com/en/tutorials/device/orientation/

您的移动浏览器必须支持btw事件。

The event, btw, must be supported by your mobile browser.

这篇关于在html5手机中检测摇晃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆