Get HTML5 Events

I am currently developing mobile web applications that make extensive use of the deviceOrientation and deviceMotion HTML5 APIs. In most mobile browsers, the event fires every 50 milliseconds, which is too slow for the accuracy I need: Is there a way to get motion data at a higher speed?

I looked at the W3C DeviceOrientation Event Specification , and I noticed that the firing speed was given by the interval devicemotion property, unfortunately readonly (plus, I'm not sure if this is only an indicator of the refresh rate implemented by the browser, or if it actually sets the refresh rate of the browser ) I saw that the initAccelerometerEvent method may allow initAccelerometerEvent to change this value, but I could not find how to use it directly in my Javascript code.

As an alternative, I thought we could get the current value of the accelerometers / gyroscopes: if such a method existed, we could use it in the setInterval method so that we set the desired refresh rate. Unfortunately, I did not find such a method.

Thus, any advice to have a higher speed driving value would be very welcome. Thank you so much for your help!

+5
source share

Source: https://habr.com/ru/post/1207655/


All Articles