1

I am trying to test hardware support for the acceleration property of a devicemotion HTMLEvent on mobile devices. As apparently those without a gyroscope only support accelerationIncludingGravity.

My first idea is to let the window object listen to devicemotion and retrieve the information, then remove the listener and add it again with a different handler. But I wonder if there's a more elegant way to test for this.

Gandora
  • 195
  • 1
  • 18
  • 1
    This may help you. http://stackoverflow.com/questions/4378435/how-to-access-accelerometer-gyroscope-data-from-javascript – sarath Oct 21 '15 at 12:30
  • @SarathMohan In the first answer of your link, in the `else if` how does he know that the device supports `acceleration`? Not all devices have a gyroscope. – Gandora Oct 21 '15 at 15:30

1 Answers1

0

I hope this plugin will help you to work with device motion via JavaScript. Accelerometer

For a demo you can check this link from mobile.

Demo Link

Mehmood
  • 933
  • 5
  • 17
  • The link to the API could not be found? – Gandora Oct 21 '15 at 15:29
  • Apple had removed that discussion. :| For some details about how to use this may be this answer will help you. http://stackoverflow.com/a/26216960/1310540 – Mehmood Oct 21 '15 at 15:34