-
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
Add way of getting current orientation #11
Comments
Agreed and we are also currently working on a native Promise-based API for this. In the mean time, you could use a library like Full Tilt JS https://github.com/richtr/Full-Tilt-JS. It simply dumps the last DeviceOrientation event object to a variable until you call a sync API function in e.g. requestAnimationFrame. At that point it performs more complex processing of the last known device orientation data. Full Tilt JS performance benchmarking is available at http://jsperf.com/screen-adjusted-deviceorientation-benchmark. |
Where is the work happening and who is involved? I tried looking for branches and PRs but couldn't find any. |
Our draft Promises proposal has now been published on the W3C Device APIs mailing list @ http://lists.w3.org/Archives/Public/public-device-apis/2014Sep/0024.html. |
It's definitely lacking. Alternatively or in addition, any thoughts on normalizing the spec for all browsers to star firing Device Orientation on the same time frame at the 'interactive' state of the document, so it can be used at or before DOMContentLoaded? My related SO post as I was trying to detect this: http://stackoverflow.com/a/30585637/1647538 |
Added label of VNext. This can be considered as part of Generic Sensor API work. |
I propose closing this issue as "won't fix". A Promise-returning API can easily be polyfilled like so, function getCurrentOrientation() {
return new Promise((resolve) => {
document.addEventListener('deviceorientation', (event) => {
resolve(event);
}, {once: true});
});
} The Observable proposal would also extend all let event = (await document.on('deviceorientation').take(1).toArray())[0]; |
The API should provide some way to get request the current orientation without needing to subscribe to events.
The text was updated successfully, but these errors were encountered: