in A List Apart called “Environmental Design”. His point was that your apps should respond to the environment they’re running in: dimming the screen in a dark room, etc.
primetime yet. Today, we can start to do something to improve our users’ experiences, even under these dynamic conditions, thanks to the recent buildup of the Device API.” http://alistapart.com/article/environmental-design-with-the-device-api Tuesday, August 6, 13 So he advocated building websites with this tech. Traditionally you’ve had to go to native code to get access.
a set of features that give browser access to more sensor inputs, where native always has had a leg up. Originally this started with Mozilla’s FirefoxOS, but lots of it is being standardized by the W3C right now. Let’s talk about three of these APIs.
+ isCharging ? 'is' : 'is not' + 'charging'); }); Tuesday, August 6, 13 Here’s an example of the code. You get a new Battery object on Navigator; as well as a set of events you can listen to as the battery level drops or when you plug into power.
lux'); }); Tuesday, August 6, 13 You get one event to hook to. The ‘value’ is measured in lux, but from my testing it appears that a reading of 100 lux on one device might translate to only 25 lux on another. So your mileage may vary.
'degrees'); }); Tuesday, August 6, 13 The main event to hook into is deviceorientation, which lets you inspect the device’s: alpha: Compass direction beta: Tilted front to back Gamma: tilted left to right Also has a DeviceMotion event, which lets you use accelerometer data
support, but here there be dragons. Big discrepancies in implementation. For example, rotating device clockwise increases the alpha value on Mobile Safari, but *decreases* it on Android Chrome. A library I wish existed: something to normalize the discrepancies. Make a name for yourself!