Detecting shaking in html5 mobile

流过昼夜 提交于 2019-12-21 04:57:06

问题


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?

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!


回答1:


You can use this jQuery plugin.

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

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




回答2:


Check this article.

DeviceOrientation is working on iOS and Android devices too.



来源:https://stackoverflow.com/questions/12334160/detecting-shaking-in-html5-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!