make it, shake it, break it€¦ · web speech api demo 40. scalable vector graphics (svg) •svg...

66
Make it, shake it, break it Funka Accessibility Days 2016 1

Upload: others

Post on 23-Sep-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Make it, shake it, break it

Funka Accessibility Days 2016

1

Page 2: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Vibration APIW3C Recommendation (2015)

2

Page 3: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

What?Enables simple haptic feedback from webapps

3

Page 4: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Why?• New email notifications

• Game effects

• Incoming call notifications

4

Page 5: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

How?• Patterns of on/off pulses

• Each pulse is described in milliseconds

• Patterns are a combination of pulses/pauses

5

Page 6: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Where?• Chrome on Android

• Chrome, Firefox and Opera on desktop

6

Page 7: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Basic HTML

<button id="v1">Vibrate once</button>

<button id="v2">Vibrate twice</button>

<button id="v3">Vibrate more</button>

7

Page 8: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Check for API support

if ("vibrate" in navigator) {

//Do something.

} else {

alert("Browser does not support the Vibration API");

}

8

Page 9: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Vibrate once

var vibrateOnce = function(e) {

window.navigator.vibrate(500);

};

9

Page 10: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Vibrate twice

var vibrateTwice = function(e) {

window.navigator.vibrate([500, 500, 500]);

};

10

Page 11: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Vibrate more

var vibrateMore = function(e) {

window.navigator.vibrate([500, 500, 500, 500, 500]);

};

11

Page 12: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Event listeners

document.getElementById("v1")

.addEventListener("click", vibrateOnce);

document.getElementById("v2")

.addEventListener("click", vibrateTwice);

document.getElementById("v3")

.addEventListener("click", vibrateMore);

12

Page 13: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Vibration API demo

13

Page 14: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

CSS Flexible Box Layout moduleW3C Candidate Recommendation (2016)

14

Page 15: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

What?Enables flexible layout control and visual ordering

15

Page 16: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Why?• Easier responsive layouts

• Drag and drop functionality

• No more float hacks

16

Page 17: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

How?• display: flex;

• order: int;

17

Page 18: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Where?Pretty much everywhere except IE before 11

18

Page 19: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Basic HTML

<div>

<button>1</button>

<button>2</button>

<button>3</button>

</div>

19

Page 20: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Unflexed buttons1 2 3

20

Page 21: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Keyboard experience

21

Page 22: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

display and order properties

<div style="display: flex;">

<button style="order: 3;">1</button>

<button style="order: 2;">2</button>

<button style="order: 1;">3</button>

</div>

22

Page 23: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Flexed buttons3 2 1

23

Page 24: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Keyboard experience

24

Page 25: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

tabindex attribute

<div style="display: flex;">

<button style="order: 3;" tabindex="3">1</button>

<button style="order: 2;" tabindex="2">2</button>

<button style="order: 1;" tabindex="1">3</button>

</div>

25

Page 26: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Spec advice?Authors must use ‘order' only for visual, not logical, reordering of content.“

26

Page 27: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

The Firefox bug

27

Page 28: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Web Speech APIW3C Community Group specification (2012)

28

Page 29: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

What?Enables speech input and output for webapps

29

Page 30: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Why?• Ask calendar for today's appointments

• Get help with complex interfaces

• Hands-free recipe books

30

Page 31: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

How?• SpeechSynthesis and SpeechRecognition interfaces

• Methods for controlling and manipulating speech output/input

31

Page 32: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Where?SpeechSynthesis interface:

• Chrome, Opera and Safari on desktop

• Chrome and Safari on mobile

SpeechRecognition interface:

• Chrome and Opera on the desktop

• Chrome on Android

32

Page 33: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Basic HTML

<button data-hint="Use space or enter to activate">

Foo

</button>

33

Page 34: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Check for API support

if (window.SpeechSynthesisUtterance === undefined) {

alert("Browser does not support the Web Speech API");

} else {

// Do something

}

34

Page 35: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Get controls with hints

hints = document.querySelectorAll('[data-hint]'),

hoverTimeout;

35

Page 36: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Create speech callback

speakHint = function(e) {

var msg =

new SpeechSynthesisUtterance(e.target.dataset.hint);

window.speechSynthesis.speak(msg);

};

36

Page 37: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Keyboard functionality

function focusEventListener(e) {

hoverTimeout = window.setTimeout(speakHint, 500, e);

}

function blurEventListener(e) {

window.clearTimeout(hoverTimeout);

}

37

Page 38: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Mouse functionality

function mouseoverEventListener(e) {

hoverTimeout = window.setTimeout(speakHint, 500, e);

}

function mouseoutEventListener(e) {

window.clearTimeout(hoverTimeout);

}

38

Page 39: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Event listeners

hints.forEach(function(hint) {

hint.addEventListener('focus', focusEventListener);

hint.addEventListener('blur', blurEventListener);

hint.addEventListener('mouseover', mouseoverEventListener);

hint.addEventListener('mouseout', mouseoutEventListener);

});

39

Page 40: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Web Speech API demo

40

Page 41: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Scalable Vector Graphics (SVG)• SVG W3C Recommendation 1.0 (2001)

• SVG 1.1 2nd edition W3C Recommendation (2011)

• SVG 2.0 W3C Working Draft (2015)

41

Page 42: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

What?Create graphics that scale without loss of quality, and which can have

semantic meaning

42

Page 43: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Why?• Responsive images

• Icons

• Reduced bandwidth

43

Page 44: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

How?Draw on-screen using elements and animations

44

Page 45: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Where?Pretty much everywhere

45

Page 46: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Rectangles

46

Page 47: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

rect element

<svg width="250" height="100">

<rect x="0" y="0" width="100%" height="100%"

style="fill: #b55fff;" />

</svg>

47

Page 48: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Circles

48

Page 49: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

circle element

<svg width="250" height="100">

<circle tabindex="0" cx="125" cy="50" r="32.5"

style="fill: #820bbb;" />

</svg>

49

Page 50: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Pentagrams

50

Page 51: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

path element

<svg width="304" height="290">

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;stroke:#000000;stroke-width:15;

stroke-linejoin:round"/>

</svg>

51

Page 52: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Scalability

52

Page 53: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Screen reader experience

53

Page 54: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

img role

<svg role="img" width="304" height="290">

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;"/>

</svg>

54

Page 55: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

title element

<svg role="img" width="304" height="290">

<title>Violet pentagram</title>

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;>

</svg>

55

Page 56: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

desc element

<svg role="img" width="304" height="290">

<title>Violet pentagram</title>

<desc>Five pointed star</desc>

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;>

</svg>

56

Page 57: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

aria-labelledby attribute

<svg role="img" aria-labelledby="title"

width="304" height="290">

<title id="title">Violet pentagram</title>

<desc>Five pointed star</desc>

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;>

</svg>

57

Page 58: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

aria-describedby attribute

<svg role="img" aria-labelledby="title"

aria-describedby="desc" width="304" height="290">

<title id="title">Violet pentagram</title>

<desc id="desc">Five pointed star</desc>

<path d="M2,111 h300 l-242.7,176.3 92.7,-285.3 92.7,285.3 z"

style="fill:#b55fff;>

</svg>

58

Page 59: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Screen reader experience

59

Page 60: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Text

Tequila

60

Page 61: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

text element

<svg width="250" height="100">

<text x="50" y="50" style="fill: #000000; font-size: 2em;">

Tequila

</text>

</svg>

61

Page 62: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Rotated text

Tequila

62

Page 63: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

transform attribute

<svg width="250" height="150">

<text x="50" y="25" style="fill: #000000; font-size: 2em;"

transform="rotate(30 20,40)">Tequila</text>

</svg>

63

Page 64: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

SVG Accessibility API Mappings (AAM)W3C Working draft (2015)

64

Page 65: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Playgroundljwatson.github.io/playground/

65

Page 66: Make it, shake it, break it€¦ · Web Speech API demo 40. Scalable Vector Graphics (SVG) •SVG W3C Recommendation 1.0 (2001) •SVG 1.1 2nd edition W3C Recommendation (2011) •SVG

Thank youQuestions?

66