Open rwaldron opened 9 years ago
Illustrative example (from Tim's proposal)
Example 2 (using requestAnimationFrame):
var sensor = null;
function updateFrame() {
window.requestAnimationFrame(updateFrame);
if (sensor)
console.log(sensor.currentOrientation);
// do something else
}
navigator.getDeviceOrientationSensor(“high”).then(
function(orientationSensor){ sensor = orientationSensor; },
function() { console.log("error"); });
window.requestAnimationFrame(updateFrame);
Would be written as:
var orientation = new sensors.Orientation({ frequency: 200 });
function updateFrame() {
window.requestAnimationFrame(updateFrame);
if (orientation.value)
console.log(orientation.value);
// do something else
}
window.requestAnimationFrame(updateFrame);
Moved to: https://github.com/w3c/sensors/issues/9
http://lists.w3.org/Archives/Public/public-device-apis/2014Sep/0024.html
As noted during the DAP call: