31
A Device API Safari Andrew Fisher @ajfisher Web Directions Code 1 May, 2014

A Device API Safari - Web Directions Code 2014

Embed Size (px)

DESCRIPTION

The Device API is what enables web browsers to appear more "native", giving the browser access to new hardware components that are being created primarily in phones and tablets but on some desktops too. Motion and Orientation are well known features of the API, however there are a plethora of others to play with too. Let's take a tour through the jungle that is the Device API spec and go looking for some new, interesting features of the API. We'll focus on the ones that will be landing in mainstream browsers soon and that you can play with now in order to explore new interaction methods. Delivered at Web Directions Code 2014 - this presentation has all the notes from the session as well as links to videos of the demos. More information like code can be found at github.com/ajfisher/wdc

Citation preview

Page 1: A Device API Safari - Web Directions Code 2014

A Device API Safari

Andrew Fisher @ajfisher

Web Directions Code 1 May, 2014

Page 2: A Device API Safari - Web Directions Code 2014

Where the wild APIs live

Page 3: A Device API Safari - Web Directions Code 2014
Page 4: A Device API Safari - Web Directions Code 2014
Page 5: A Device API Safari - Web Directions Code 2014

Sensor API

Ambient Temperature

Ambient Humidity

Atmospheric Pressure

Page 6: A Device API Safari - Web Directions Code 2014

Sensor based content

Page 7: A Device API Safari - Web Directions Code 2014

Upgrade your NodeBot

Page 8: A Device API Safari - Web Directions Code 2014

Web NFC

Page 9: A Device API Safari - Web Directions Code 2014

Web NFC

Page 10: A Device API Safari - Web Directions Code 2014

Network APIs

Page 11: A Device API Safari - Web Directions Code 2014
Page 12: A Device API Safari - Web Directions Code 2014

Proximity API

DeviceProximityEvent

UserProximityEvent

Page 13: A Device API Safari - Web Directions Code 2014

DeviceProximityEvent

Event Object:

value; // distance detected

max; // maximum distance capable

min; // minimum distance capable

Page 14: A Device API Safari - Web Directions Code 2014

UserProximityEvent

Event Object:

near; // true if inside detection zone

Page 15: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_proximity

(video) http://youtu.be/7cgug03jmVw

Page 16: A Device API Safari - Web Directions Code 2014

Battery Status API

Page 17: A Device API Safari - Web Directions Code 2014

Battery Status API

chargingchange

chargingtimechange

dischargingtimechange

levelchange

Page 18: A Device API Safari - Web Directions Code 2014

Battery Status API

BatteryManager Object:

charging; // true if charging

chargingTime; // time to fully charged in seconds

dischargingTime; // time to flat in seconds

level ; // percent charged

[0..1]

Page 19: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_battery

Page 20: A Device API Safari - Web Directions Code 2014

Leaving the wilderness

Page 21: A Device API Safari - Web Directions Code 2014
Page 22: A Device API Safari - Web Directions Code 2014

Vibration API

navigator.vibrate(msec);

navigator.vibrate([msec on, msec off, msec on, msec off..]);

navigator.vibrate(0);

Page 23: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_racer

(video) https://www.youtube.com/watch?v=0AC_InC0QMA

Page 24: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_vibroform

Page 25: A Device API Safari - Web Directions Code 2014

Ambient Light API

Page 26: A Device API Safari - Web Directions Code 2014

DeviceLight Event

Event Object:

value; // amount of light from sensor in lux

Page 27: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_contrast

Page 28: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_contrast

Page 29: A Device API Safari - Web Directions Code 2014

ajf.io/wdc_ghosts

(video) http://youtu.be/E2Eu5gRvkME

Page 30: A Device API Safari - Web Directions Code 2014
Page 31: A Device API Safari - Web Directions Code 2014

A Device API Safari

@ajfisher

github.com/ajfisher/wdc