11
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

Device API - now with added fun

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

Page 1: Device API - now with added fun

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

Page 2: Device API - now with added fun

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

Page 3: Device API - now with added fun

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).

Page 4: Device API - now with added fun

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)

Page 5: Device API - now with added fun

Demos were presented on LAN. See http://github.com/ajfisher for more

Let's see some data

Page 6: Device API - now with added fun

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);

}

Page 7: Device API - now with added fun

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);}

Page 8: Device API - now with added fun

Demos were presented on LAN. See http://github.com/ajfisher for more

Applications

Page 9: Device API - now with added fun

Demos were presented on LAN. See http://github.com/ajfisher for more

Seismographhttp://isthisanearthquake.com

Page 10: Device API - now with added fun

Demos were presented on LAN. See http://github.com/ajfisher for more

Tank Tag

Page 11: Device API - now with added fun

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