State of Mobile HTML5
2013 - 2014

Tomomi Imura, @girlie_mac

State of Mobile Web

Have smartphone browsers gotten smarter?

Tomomi Imura @girlie_mac

html5 mug

Public domain photo from NASA, modifed with https://flic.kr/p/Ea32T by Andrewb

google mobile strategy in 2007

https://flick.kr/p/3fzVnW by Danny Sullivanb

HTML5 on mobile

Mobile Browser Releases 2013 -

Chrome Android Constant Releases

Chrome: WebKit -> Blink

Opera: Presto -> WebKit -> Blink

IndexedDB

SPDY

CSS Flexbox (New Spec)

ES: Promises, Object.observe()

Flat Icons

Mobile Browser Usage Stats

StatCounter Global Stats - Browser Market Share

Disrupt App Store

html5 mug

https://flic.kr/p/5r6RYe by Cristiano Bettab

Distributing outside of app stores

flappybird.io2048

Forking (in Doge style)

Flappy DogeDoge2048

and Flappy 2048

Flappy 2048

Hardware Access

cat in dryer

https://flic.kr/p/54oAAr by James Cridlandb

HW Access with Device APIs

Sensors

Demo: http://girliemac.github.com/sushi-compass

Last Year

"Coremob
Camera"

Coremob Camera app on Android

Project Goals

  1. Showcase the capabilities of the Web platform
  2. Educate Web developers
  3. Help improve browsers

HTML5 APIs

  1. Take a picture via HTML Media Capture
  2. Use FileReader() to return the picture as a object
  3. drawImage() to draw the image object in canvas
  4. getImageData() to get an ImageData object containing a copy of the pixel data, then alter the pixels
  5. Store the blob locally with IndexedDB
  6. Upload the final photo with XHR2/CORS

HTML Media Capture

Coremob Camera app

Taking a photo with using a native camera


<input type="file" accept="image/*">
		
18
15bl
3
10
6
10
10
11

File API

Camera returns the photo as a file object

var input = document.querySelector('input[type=file]'); 
input.addEventListener('change', function() {
    var localFile = input.files[0];
    var reader = new FileReader();
    reader.readAsDataURL(localFile);
    reader.onload = function(e){
        preview.src = e.target.result;
    }
}, false);
		
		

Canvas

Coremob Camera app

Applying filters to the photo


var c = document.createElement('canvas');
var ctx = this.c.getContext('2d');
ctx.drawImage(imgObj, 0, 0);
var imgData = ctx.getImageData(x, y, w, h); 
//...Pixel manipulation ...
ctx.putImageData(imgData, 0, 0); 
		
		
7
9

IndexedDB

Coremob Camera app

Storing the photos locally


if(window.indexedDB) {
   var req = indexedDB.open('coremobCamera'); 
   req.onsuccess = function(e) {
      // async
   }
}

IndexedDB Support

Coremob Camera app New in 2014:
18*
25
15bl
10*
16
10
4.4
8

Inspect IndexedDB in Chrome

...and now in Aurora too!

https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector

XMLHttpRequest Level 2

Coremob Camera app

Sending a photo


var formData = new FormData();
formData.append('photo', blob); 
		
3
5
10
12
15bl

Touch Events v.1

Coremob Camera app

Photo Gallery Carousel


el.addEventListener('touchstart', 
                    startHandler, false);
el.addEventListener('touchmove'...);
el.addEventListener('touchend'...);
		

You probably want to include mouse events too (mousedown, mousemove, and mouseup).

Pointer Events

Micorsoft Pointer event diagram

For any input devices: touch, mouse, pen...


if (typeof window.PointerEvent != 'undefined') {
   el.addEventListener('pointerdown', 
                         startHandler, false);
   el.addEventListener('pointermove', ...);
   el.addEventListener('pointerup', ...);
}
		

Touch vs. Pointer Events

Touch Pointer
Chrome 37 Yes will implement ->
No, they changed mind
Opera 22 Yes No
Firefox 26 Yes No
IE 10 No Yes
IE 11.next Yes Yes
Safari 7 Yes No
Android 4.4 Yes No

caniuse.com • groups.google.com/a/chromium.org

To-do list for the camera app

Keep up to date

html5 mug

https://flic.kr/p/8tuc1u by randomliteraturecouncilb

Chromium Dashboard

IE Platform Status

Thank you <3

Tomomi Imura