Giter Club home page Giter Club logo

Comments (6)

richtr avatar richtr commented on July 28, 2024

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.

from deviceorientation.

marcoscaceres avatar marcoscaceres commented on July 28, 2024

Where is the work happening and who is involved? I tried looking for branches and PRs but couldn't find any.

from deviceorientation.

richtr avatar richtr commented on July 28, 2024

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.

from deviceorientation.

hexalys avatar hexalys commented on July 28, 2024

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

from deviceorientation.

gmandyam avatar gmandyam commented on July 28, 2024

Added label of VNext. This can be considered as part of Generic Sensor API work.

from deviceorientation.

reillyeon avatar reillyeon commented on July 28, 2024

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 EventTargets so that you could write:

let event = (await document.on('deviceorientation').take(1).toArray())[0];

from deviceorientation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.