Mobile Safari gets orientation API in iOS 4.2 for tilt-sensitive sites

Apple has opened up accelerometer and gyroscope access to mobile Safari web developers in iOS 4.2, meaning iPhone, iPod touch and iPad sites can potentially be controlled by those motion sensors. Developer Maximiliano Firtman spotted the update, which appears to be based on the W3C draft for the DeviceOrientation API; he's also thrown together a quick rolling-ball demo, which you can see after the cut.Video demo after the cut

The sample uses JavaScript and some CSS3, and basically allows the ball's movement to be controlled by the direction the smartphone is being tilted in. You can try it on a mobile Safari browser at http://ad.ag/wjmtgt. Similar access to the iOS orientation APIs has been available for iOS SDK users – creating native apps – for some time now, but this is the first time that the same hardware access has been made available for web app devs.

The new functionality opens up the possibility of motion-sensitive web games, navigation of complex web pages by simply tilting the phone, and augmented reality apps that do not have to be locally stored on the iOS device. Meanwhile Apple has also added the WebSockets API, updated their HTML5 Form support and made other tweaks.

[via Pocket-lint]