Hacker News new | past | comments | ask | show | jobs | submit login
Accessing device orientation in pure JavaScript (trekhleb.dev)
25 points by EntICOnc on March 7, 2021 | hide | past | favorite | 6 comments



Firefox 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/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.


I believe the desire is for people to use the Sensor API instead now:

https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs


hmmmm firefox is missing this API as well


The "Gyro-Cube" example seems to have the alpha and gamma angles swapped.


I'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.


Very useful as a pre-baked React hook, thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: