Upload
andrew-fisher
View
3.309
Download
0
Embed Size (px)
DESCRIPTION
Device Motion and Device Orientation are two new events we can play with inside mobile browsers. This quick 5 min presentation shows how to use them and some application demos.Originally presented as part of Web Directions - What Do you Know night in Melbourne, 31 August, 2011.Live demos have been screengrabbed but code is available at github.com/ajfisher
Citation preview
Demos were presented on LAN. See http://github.com/ajfisher for more
Mobile Device API -Now with added fun
@ajfisher slideshare.net/andrewjfisher
#wdyk Melbourne 31 August, 2011
Demos were presented on LAN. See http://github.com/ajfisher for more
Two new eventsDEVICEMOTIONMeasures acceleration of the device
DEVICEORIENTATIONShows the orientation of a device
Demos were presented on LAN. See http://github.com/ajfisher for more
Currently supported on:Mobile Safari
(iPhone 3Gs+ for motion, iPhone 4+ for orientation)
Mobile Firefox (Android 2.3+ only)
Chrome & Safari (Dev) on desktops that have the right hardware
Opera 11 Mobile (must enable it manually).
Demos were presented on LAN. See http://github.com/ajfisher for more
GotchasCurrent spec still draft (latest July 12, 2011)
http://bit.ly/devicespec
Data inconsistent between browsersComing library to resolve these (github.com/ajfisher)
Demos were presented on LAN. See http://github.com/ajfisher for more
Let's see some data
Demos were presented on LAN. See http://github.com/ajfisher for more
Usage - deviceorientationwindow.addEventListener("deviceorientation", update_gyro, false);
function update_gyro(e) {
// gets the gyro position
var tilt = deviceOrientation(e);
$("#xval").html(tilt.gamma);
$("#yval").html(tilt.beta);
$("#zval").html(tilt.alpha);
}
Demos were presented on LAN. See http://github.com/ajfisher for more
Usage - devicemotionwindow.addEventListener("devicemotion", update_accel,
false);function update_accel(e) { // gets the accelerometer values var a = deviceMotion(e); $("#xaccel").html(a.accelerationIncludingGravity.x); $("#yaccel").html(a.accelerationIncludingGravity.y); $("#zaccel").html(a.accelerationIncludingGravity.z);}
Demos were presented on LAN. See http://github.com/ajfisher for more
Applications
Demos were presented on LAN. See http://github.com/ajfisher for more
Seismographhttp://isthisanearthquake.com
Demos were presented on LAN. See http://github.com/ajfisher for more
Tank Tag
Demos were presented on LAN. See http://github.com/ajfisher for more
Mobile Device API -Now with added fun#wdyk Melbourne 31 August, 2011
@ajfisher slideshare.net/andrewjfisher