1 of 19

Pointer Events

vs.

Touch Events

in Blink

Rick Byers - Nov 4, 2014

2 of 19

Problems

Why introduce pointer events?

3 of 19

Problems

  • Developers want to be able to use the same code for multiple input devices.

4 of 19

Code sharing

Lines of code

Delta

Mouse only (single)

60

73

13

131

71

86

26

89

29

5 of 19

Problems

if ('ontouchstart' in window)

element.addEventListener('touchstart', activate);

else

element.addEventListener('mousedown', activate);

JS

  • Assumptions that touch event support is mobile only

6 of 19

Problems

  • Interoperability issues��

7 of 19

Problems

  • Scrolling always blocks on touchstart

demo

8 of 19

Pointer Events?

Are they a good fit for blink priorities?

9 of 19

Blink Priorities

  • Mobile first

Interoperability with Safari is critical

Touch events are the best hope for a single API

Easily adapting mouse code is no longer our goal

10 of 19

Blink Priorities

  • Apps as rich as on Android/iOS

Performance

Richness

Rationality

11 of 19

Blink Priorities

  • Performance

Minor in practice - disadvantage in principle

2.5% frame hit-test penalty

Risk of double event dispatch

12 of 19

Evolving

Touch Events

Another way to address the problems

13 of 19

Evolving Touch Events

  • Improve interoperability on mobile

Converging behavior while scrolling

Details in Chrome, Safari, IE

14 of 19

Evolving Touch Events

  • Fix device confusion issues

Evangelism

Interaction media queries

Event de-duplication

15 of 19

Evolving Touch Events

  • Enable touch event API all the time�

16 of 19

Evolving Touch Events

  • Non-blocking scroll opt-in

17 of 19

Evolving Touch Events

  • Improve mouse/stylus support on Android

TouchEvent.pointerType

TouchEvent.buttons

touchhover

Element.setTouchCapture

...

18 of 19

Evolving Touch Events

  • Universal touch events opt-in?

19 of 19

Debate

What should we be doing differently?