Hell is other browsers - Sartre. The touch events. Peter-Paul Koch (ppk) DIBI, 28 April 2010

Similar documents
Hell is other browsers - Sartre. The touch events. Peter-Paul Koch (ppk) WebExpo, 24 September 2010

JavaScript and Events

Developing for touch. Peter-Paul Koch Mobilism, 16 and 17 May 2013

5/19/2015. Objectives. JavaScript, Sixth Edition. Using Touch Events and Pointer Events. Creating a Drag-and Drop Application with Mouse Events

Hell is other browsers - Sartre. Ajax Workshop. Peter-Paul Koch (ppk) Fundamentos del Web, 28 October 2008

Catching Events. Bok, Jong Soon

CS193X: Web Programming Fundamentals

Improving the Accessibility and Usability of Complex Web Applications

Touch Forward. Bill Fisher. #touchfwd. Developing Awesome Cross-Browser Touch

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world

729G26 Interaction Programming. Lecture 4

Write a Touch-friendly HTML5 App. Hongbo Min, Intel Junmin Zhu, Intel Yongsheng Zhu, Intel

CSE 154 LECTURE 10: MORE EVENTS

Web App Vs Web Site. Some tricks of the trade. Laurent Technical Director, BlackBerry Web Platform

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

State of the Browsers

JavaScript Handling Events Page 1

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM

Definitions. Interfaces. Example. Create a canvas. Setting up the event handlers. Tracking new touches

j I 8 EVENTS INTERACTI O NS EVENTS TRI GGER CODE RESPONDS CREATE EV ENTS CODE TO USERS

Skyway Builder Web Control Guide

shift from the page Bill Scott Yahoo! Ajax Evangelist

Information Design. Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212

Web Design. Lecture 6. Instructor : Cristina Mîndruță Site : Cristina Mindruta - Web Design

Photo from DOM

JSF. JSF and Ajax Basics

Web standards and IE8

Lifespan Guide for installing and using Citrix Receiver on your Mobile Device

B. V. Patel Institute of Business Management, Computer and Information Technology, UTU. B. C. A (3 rd Semester) Teaching Schedule

skb2 Shaon Barman, Sarah Chasins, Ras Bodik UC Berkeley Sumit Gulwani Microsoft Research

I'm Remy. Who uses jquery.

Script for Administering the Civics EOC Practice Test (epat)

First we start by importing our image assets to our "Chapters" card

TurnerTime Time & Technology Training How to Use the Snipping Tool to Capture all/part of Screen (Windows 10)

EECS1012. Net-centric Introduction to Computing. Lecture JavaScript Events

A pixel is not a pixel. Peter-Paul Koch SF HTML5, 6 April 2012

Lesson 15 - How to Work with Thread Set Threads System Table

Android Pre-Release Deployment Release Notes (R2)

Creating Content with iad JS

Produced by. App Development & Modeling. BSc in Applied Computing. Eamonn de Leastar

Web Programming Step by Step

Prezi Creating a Prezi

User Guide. General Navigation

1. Move your mouse to the location you wish text to appear in the document. 2. Click the mouse. The insertion point appears.

Overview In this lab you will Explore some of the features of the new Windows 8 Interface.

of numbers, converting into strings, of objects creating, sorting, scrolling images using, sorting, elements of object

JavaScript: Events, DOM and Attaching Handlers

2D1640 Grafik och Interaktionsprogrammering VT Good for working with different kinds of media (images, video clips, sounds, etc.

VBA Foundations, Part 7

1. Click the Share menu at the top of the screen and then click File (Including Video)

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?

Remote Desktop Services Guide. Android DG ITEC ESIO - STANDARDS

How to Connect to the CSH Virtual Desktop

A pixel is not a pixel. Peter-Paul Koch MoBeers, 10 April 2012

Mouseless Internet Browsing for Open V/Vmax Devices

Interacting with Measurement Studio Graphs in Visual Basic Heather Edwards

Outline. Lecture 4: Document Object Model (DOM) What is DOM Traversal and Modification Events and Event Handling

Font Awesome Icon User Guide

Today s Hall of Fame or Shame example is a feature of Microsoft Office 2007 that gives a preview of what a style command will do to the document

Citrix Client Installation and Configuration

ROUTED EVENTS. Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

3. Surfing with Your ipad

CST242 Windows Forms with C# Page 1

Customizing DAZ Studio

ACT-Touch. Cogscent, LLC. ACT-R gets its Hands on a Multitouch Display Frank Tamborello & Kristen Greene

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Computer Basics. Need more help? What s in this guide? Types of computers and basic parts. Why learn to use a computer?

Viewports. Peter-Paul Koch CSS Day, 4 June 2014

CST272 Getting Started Page 1

Flip-Q. Version 2.4. Overview

CST272 Getting Started Page 1

JavaScript is described in detail in many books on the subject, and there is excellent tutorial material at

User Guide. Campus Connect

Windows Movie Maker / Microsoft Photo Story Digital Video

Introduction to Kaltura

How To Capture Screen Shots

NetAdvantage for ASP.NET Release Notes

Windows 8.1 It s a Good System. SIR Phil Goff Branch 116 November 21, 2013

Overview. Event Handling. Introduction. Reviewing the load Event. Event mousemove and the event Object. Rollovers with mouseover and mouseout

Introduction to Word 2010

Word Processing. 2 Monroe County Library System

INFOhio Symphony Handbook ebooks in ISearch. ISearch ebook Connector

Quick Reference Guide WebEx on an ipad

The specific tasks described in this Cheat Sheet are grouped based on which of the following more general tasks they relate to.

Creating a Presentation

Exploring Windows 8. Starting Windows 8 for the First Time. About Windows 8 User Interface and Features. Get Started. Unlock Your Computer and Sign In

1. Cascading Style Sheet and JavaScript

jquery Tutorial for Beginners: Nothing But the Goods

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

Events. Mendel Rosenblum. CS142 Lecture Notes - Events

Mobile: OneNote. Microsoft Quick Start ITS (2017)

User Manual. Version 1.2

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape

Ignite UI Release Notes

Getting Started: Workday Basics Page 1 of 16. Getting Started: Workday Basics

PAGES, NUMBERS, AND KEYNOTE BASICS

Introduction to WISER: Departments

City of Mobile GIS Web Mapping Applications: New Technology, New Expectations

How to Access Your Digital Member Magazine

Transcription:

Hell is other browsers - Sartre The touch events Peter-Paul Koch (ppk) http://quirksmode.org http://twitter.com/ppk DIBI, 28 April 2010

The desktop web Boring! - Only five browsers with only one viewport each that support nearly everything Even IE? Yes, even IE.

The Mobile Web Exciting! - Fifteen browsers and counting ranging from great to lousy Interesting new bugs About five times as many users as the desktop web (eventually) - New interaction modes

The Mobile Web Exciting! - Fifteen browsers and counting ranging from great to lousy Interesting new bugs About five times as many users as the desktop web (eventually) - New interaction modes

Before we start please open the following link on your iphone or Android: http://quirksmode.org/touchevents It gives links to the test files.

Mouse

Mouse Keyboard

Mouse Keyboard Touch

Mouse Keyboard users need different interaction than mouse users need different interactions than touch users. Your script accomodates all three modes, right? It's all a question of events.

keydown keypress keyup

mouseover mouseout mousedown mouseup mousemove

touchstart touchmove touchend touchcancel

It's not an either-or proposition.

It's not an either-or proposition. The Nokia E71 has a four-way navigation. Works like the arrow keys (including keycodes). But...

It's not an either-or proposition. But... the arrow keys steer a mouse cursor. Key events and mouse events

Today we'll concentrate on the touch events, though.

Touch!== mouse - Area Pressure Temperature more than one touch

http://quirksmode.org/touchevents Open the first dropdown example. Task: Click on option 3.2 This is with traditional mouseover and mouseout; no touch-specific code. Works (a bit oddly, but works).

dropdown.onmouseover = function (e) { // open dropdown dropdown.onmouseout = function (e) { // close dropdown // if appropriate dropdown.onmouseout = null } }

http://quirksmode.org/touchevents Now open the second dropdown example. Task: Click on option 3.2 Doesn't work.

dropdown.onmouseovertouchstart = function (e) { // open dropdown dropdown.onmouseouttouchend = function (e) { // close dropdown // if appropriate dropdown.onmouseout = null } } Not an entirely fair comparison.

Not an entirely fair comparison. Touchstart and touchend are not the equivalents of mouseover and mouseout. Still, there is no better option. Besides, it shows how different touch interaction is from mouse interaction.

Interaction modes Mouse Keyboard Touch mousedown mousemove mouseup mouseover mouseout All keydown keypress keyup focus blur All touchstart touchmove touchend iphone, Android

There is no true hover on a touchscreen. No way of saying I might be interested in this element but I'm not sure yet. Instead, the mobile browsers fake mouseover/out and :hover. (We'll see how later.)

Interaction modes Mouse Keyboard Touch mousedown mousemove mouseup mouseover mouseout keydown keypress keyup focus blur touchstart touchmove touchend - load, unload, click, submit, resize, zoom, change etc. etc.

Interaction modes Mouse Keyboard Touch mousedown mousemove mouseup mouseover mouseout keydown keypress keyup focus blur touchstart touchmove touchend - load, unload, click, submit, resize, zoom, change etc. etc.

Interaction modes Mouse Keyboard Touch mousedown mousemove mouseup mouseover mouseout keydown keypress keyup focus blur touchstart touchmove touchend - load, unload, click, submit, resize, zoom, change etc. etc.

Interaction modes Mouse Keyboard Touch mousedown mousemove mouseup mouseover mouseout keydown keypress keyup focus blur touchstart touchmove touchend - load, unload, click, submit, resize, zoom, change etc. etc.

In theory a touchscreen device should fire only the touch events, and not the mouse events. However, too many websites depend on the mouse events, so touch browser vendors are forced to support them, too.

Therefore, when you touch the screen of a touchscreen, both touch and mouse events fire. But the mouse events are a bit special. They all fire at the same time.

http://quirksmode.org/touchevents You can test the events for yourself at the touch action test page.

touchstart mouseover mousemove (only one!) mousedown mouseup click :hover styles applied

When the user touches another element mouseout :hover styles removed On the iphone this element must listen to events. If it doesn't, it's not clickable and events do not fire.

touchstart mouseover mousemove mousedown mouseup click :hover styles If a DOM change occurs onmouseover or onmousemove, the rest of the events is cancelled. (iphone and Symbian) applied

http://quirksmode.org/touchevents Now open the first drag-and-drop example. Should work fine; both on touch devices and with a mouse. This is very simple.

element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } }

element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } } Set mousemove and mouseup handlers only when mousedown has taken place. May save some processing time; especially on mobile.

element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } } Set mousemove and mouseup handlers on the document. Helps when user moves too fast and overshoots : the script remains functional.

element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } }

element.ontouchstart = function (e) { // initialise document.ontouchmove = function (e) { // move } document.ontouchend = function (e) { document.ontouchmove = null; document.ontouchend = null; } } But: how do we know which events to use? How do we know whether a user uses a mouse or a touchscreen?

element.onmousedown = function (e) { document.onmousemove = etc. document.onmouseup = etc. } element.ontouchstart = function (e) { document.ontouchmove = etc. document.ontouchend = etc. }

element.onmousedown = function (e) { document.onmousemove = etc. document.onmouseup = etc. } element.ontouchstart = function (e) { element.onmousedown = null; document.ontouchmove = etc. document.ontouchend = etc. } Remove the mousedown event handler when a touchstart takes place: now you're certain that the user uses a touchscreen.

http://quirksmode.org/touchevents Now open the second drag-and-drop example. iphone only. Try dragging two or all three layers simultaneously. (A bit stilted, but you get the point.)

This is impossible on a desktop computer. Two mice? Useful for games, maybe (especially on the ipad). Does not work on Android: the browser doesn't (yet) support true multitouch.

http://quirksmode.org/touchevents Now open the scrolling layer example. Works fine on mobile. But how do we port this to the other interaction modes? - keys: use arrow keys - mouse:???

Interaction modes - mouse keyboard touch and a fourth...

Interaction modes - mouse keyboard touch trackball Generally fires a mousemove event

Thank you! Questions? http://quirksmode.org http://twitter.com/ppk