4 ms·
Accessing device orientation in pure JavaScript
- jwalton 6y agoThe "Gyro-Cube" example seems to have the alpha and gamma angles swapped.
- atum47 6y agoI've written a simple move the ball to a hole game, with simple physics, using this features. One thing I had to take in account is when you flip your phone, the values are inverted.
- chrismorgan 6y agoFirefox is producing this warning on the `window.addEventListener('deviceorientation', onDeviceOrientation);` line: > Use of the orientation sensor is deprecated. No further information. I see no mention of deprecation at https://developer.mozilla.org/en-US/docs/Web/API/Window/deviceorientation_event https://developer.mozilla.org/en-US/docs/Web/API/Window/devi..., so I’m not sure of the true state of affairs. It could have been accidentally tagged along with other functionality that is deprecated.
- afavour 6y agoI believe the desire is for people to use the Sensor API instead now: https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs
- lilgreenland 6y agohmmmm firefox is missing this API as well
- jack_riminton 6y agoVery useful as a pre-baked React hook, thanks!