-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guidance needed: how to acquire compass headings in a future-compatible manner? #137
Comments
Summoning @marcoscaceres Discussed in https://www.w3.org/2024/02/12-dap-minutes.html#t10 |
Just noting that registering a listener shouldn't have any side effects (i.e., it doesn't automatically enable the machinery to start firing the events). One would still need to request permission. In WebKit specifically, we don't implement "deviceorientationabsolute" it seems. It seems Gecko does... but I haven't confirmed how it works there. @rakuco, I saw you took an action to look into what Gecko does... could you still do that? I'd like to get a complete picture of what each browser is doing and then we can look at aligning everything in the spec. |
Today there exists an event deviceorientationabsolute that can be used to register to device orientation events that are relative to the magnetic north pole (for 1D compass heading calculations)
This event is available on other browsers except Safari.
On Safari
window.addEventListener('deviceorientationabsolute', ...)
does not work, but instead one must first callDeviceOrientationEvent.requestPermission()
and after that Promise resolves to a success, register to thewindow.addEventListener('deviceorientation', ...)
event, and useDeviceOrientationEvent.webkitCompassHeading
to acquire the 1D compass heading direction.In other browsers today, I understand that one does not need to call
DeviceOrientationEvent.requestPermission()
before registering adeviceorientationabsolute
event handler, though I presume that since the function is in the spec, that in the future this may also be required.But this gives a problem: what kind of code should one write in order to precisely register to get 1D compass heading directions in a manner that will be forward-compatible to future Firefox, Chrome and Safari browsers?
We can feature test whether
DeviceOrientationEvent.requestPermission()
exists and call it before registering a handler, but how does one know precisely whether to register'deviceorientation'
or'deviceorientationabsolute'
events?The text was updated successfully, but these errors were encountered: