开发者

Android browser shake detection with javascript for a web application

开发者 https://www.devze.com 2023-03-02 04:12 出处:网络
Do any versions of androids web browser detect javascript shake events? Something like this: window.addEventListener(\'devicemotion\', this, false);

Do any versions of androids web browser detect javascript shake events? Something like this:

window.addEventListener('devicemotion', this, false);

I can't seem to find any information on this.

I am using WKShake which is refrenced here: Javascript. Listen for iPhone shake event?

and am wondering i开发者_开发百科f this is going to work on android as well.


After some research, I have discovered that the android browser does not have access to accelerometer data. Perhaps some time in the future they will allow the browser to access this data.


Shake.js (http://functionn.blogspot.com/2012/03/shakejs-custom-shake-event-javascript.html) is a custom 'shake' event JavaScript plugin for mobile web browsers using device accelerometer. Your web browser must support the devicemotion event for this plugin to work. Shake.js uses built-in feature detection to determine if it can run in your web browser. It will terminate silently on non-supporting browsers.


Here's an implementation of a JavaScript shake method for Android built on top of PhoneGap's accelerometer API - github link

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号