SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
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
Keyboard users need different Mouse
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   keydown    touchstart
mousemove   keypress   touchmove
mouseup     keyup      touchend
mouseover   focus      -
mouseout    blur       -
All         All        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     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
load, unload, click, submit, resize,
zoom, change etc. etc.
Interaction modes
Mouse         Keyboard Touch
mousedown     keydown        touchstart
mousemove     keypress       touchmove
mouseup       keyup          touchend
mouseover     focus          -
mouseout      blur           -
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      If a DOM change occurs
mouseover       onmouseover or
mousemove       onmousemove, the rest
mousedown       of the events is cancelled.
mouseup         (iPhone and Symbian)
click
:hover styles   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

Mais conteúdo relacionado

Mais procurados

Keyboard and mouse events in python
Keyboard and mouse events in pythonKeyboard and mouse events in python
Keyboard and mouse events in pythonmal6ayer
 
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...Getting touchy - an introduction to touch and pointer events / Frontend NE / ...
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...Patrick Lauke
 
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events (complete master...
Getting touchy - an introduction to touch and pointer events (complete master...Getting touchy - an introduction to touch and pointer events (complete master...
Getting touchy - an introduction to touch and pointer events (complete master...Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Patrick Lauke
 
дыдыкин егор
дыдыкин егордыдыкин егор
дыдыкин егорkuchinskaya
 
Flash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listFlash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listSmall Screen Design
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sitesAspenware
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoLittleBIGRuby
 
YUI for Mobile - HTML5DevConf 11
YUI for Mobile - HTML5DevConf 11YUI for Mobile - HTML5DevConf 11
YUI for Mobile - HTML5DevConf 11Gonzalo Cordero
 
Developing social simulations with UbikSim
Developing social simulations with UbikSimDeveloping social simulations with UbikSim
Developing social simulations with UbikSimEmilio Serrano
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceChristian Heilmann
 

Mais procurados (15)

Keyboard and mouse events in python
Keyboard and mouse events in pythonKeyboard and mouse events in python
Keyboard and mouse events in python
 
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...Getting touchy - an introduction to touch and pointer events / Frontend NE / ...
Getting touchy - an introduction to touch and pointer events / Frontend NE / ...
 
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
Getting touchy - an introduction to touch events / Webinale / Berlin 04.06.2013
 
Getting touchy - an introduction to touch and pointer events (complete master...
Getting touchy - an introduction to touch and pointer events (complete master...Getting touchy - an introduction to touch and pointer events (complete master...
Getting touchy - an introduction to touch and pointer events (complete master...
 
Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...Getting touchy - an introduction to touch and pointer events / Future of Web ...
Getting touchy - an introduction to touch and pointer events / Future of Web ...
 
дыдыкин егор
дыдыкин егордыдыкин егор
дыдыкин егор
 
Flash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic listFlash Lite & Touch: build an iPhone-like dynamic list
Flash Lite & Touch: build an iPhone-like dynamic list
 
ev
evev
ev
 
Ms Ajax Dom Event Class
Ms Ajax Dom Event ClassMs Ajax Dom Event Class
Ms Ajax Dom Event Class
 
Fast multi touch enabled web sites
Fast multi touch enabled web sitesFast multi touch enabled web sites
Fast multi touch enabled web sites
 
Wii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont DoWii Ruby All Work And No Play Just Wont Do
Wii Ruby All Work And No Play Just Wont Do
 
Yui mobile
Yui mobileYui mobile
Yui mobile
 
YUI for Mobile - HTML5DevConf 11
YUI for Mobile - HTML5DevConf 11YUI for Mobile - HTML5DevConf 11
YUI for Mobile - HTML5DevConf 11
 
Developing social simulations with UbikSim
Developing social simulations with UbikSimDeveloping social simulations with UbikSim
Developing social simulations with UbikSim
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax Experience
 

Destaque

Social Media Analysis for Government Communicators
Social Media Analysis for Government CommunicatorsSocial Media Analysis for Government Communicators
Social Media Analysis for Government CommunicatorsAndrew Einhorn
 
The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...Brian Solis
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source CreativitySara Cannon
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)maditabalnco
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsBarry Feldman
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome EconomyHelge Tennø
 

Destaque (7)

Social Media Analysis for Government Communicators
Social Media Analysis for Government CommunicatorsSocial Media Analysis for Government Communicators
Social Media Analysis for Government Communicators
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 
The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...The impact of innovation on travel and tourism industries (World Travel Marke...
The impact of innovation on travel and tourism industries (World Travel Marke...
 
Open Source Creativity
Open Source CreativityOpen Source Creativity
Open Source Creativity
 
Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)Reuters: Pictures of the Year 2016 (Part 2)
Reuters: Pictures of the Year 2016 (Part 2)
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Semelhante a Touchevents

Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Patrick Lauke
 
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Patrick Lauke
 
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Patrick Lauke
 
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Patrick Lauke
 
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Patrick Lauke
 
Yahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsYahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsPeter-Paul Koch
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesEthan Cha
 
Alice05
Alice05Alice05
Alice05h2vs10
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhoneErin Dees
 
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Patrick Lauke
 
CSS for Touch Devices
CSS for Touch DevicesCSS for Touch Devices
CSS for Touch DevicesEmma Woods
 
1 module mouse basics
1 module mouse basics1 module mouse basics
1 module mouse basicsRozell Sneede
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sitesAspenware
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & ButtonsDeep Patel
 
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Patrick Lauke
 

Semelhante a Touchevents (20)

Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
 
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
Getting touchy - an introduction to touch events / Sud Web / Avignon 17.05.2013
 
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...Getting touchy - an introduction to touch and pointer events (1 day workshop)...
Getting touchy - an introduction to touch and pointer events (1 day workshop)...
 
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
Getting touchy - an introduction to touch events / Web Standards Days / Mosco...
 
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
Getting touchy - Introduction to touch (and pointer) events / jQuery Europe 2...
 
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...Getting touchy - an introduction to touch and pointer events / Smashing Confe...
Getting touchy - an introduction to touch and pointer events / Smashing Confe...
 
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
Getting touchy - an introduction to touch and pointer events / Workshop / Jav...
 
Yahoo presentation: JavaScript Events
Yahoo presentation: JavaScript EventsYahoo presentation: JavaScript Events
Yahoo presentation: JavaScript Events
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And Types
 
Alice05
Alice05Alice05
Alice05
 
Cucumber meets iPhone
Cucumber meets iPhoneCucumber meets iPhone
Cucumber meets iPhone
 
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
Getting touchy - an introduction to touch and pointer events / Sainté Mobile ...
 
CSS for Touch Devices
CSS for Touch DevicesCSS for Touch Devices
CSS for Touch Devices
 
1 - Mouse Basics
1 - Mouse Basics1 - Mouse Basics
1 - Mouse Basics
 
3 module basic hardware
3 module basic hardware3 module basic hardware
3 module basic hardware
 
1 module mouse basics
1 module mouse basics1 module mouse basics
1 module mouse basics
 
Tips for building fast multi touch enabled web sites
 Tips for building fast multi touch enabled web sites Tips for building fast multi touch enabled web sites
Tips for building fast multi touch enabled web sites
 
DHTML - Events & Buttons
DHTML - Events  & ButtonsDHTML - Events  & Buttons
DHTML - Events & Buttons
 
Basic computer-skills1
Basic computer-skills1Basic computer-skills1
Basic computer-skills1
 
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
Getting touchy - an introduction to touch and pointer events (Workshop) / Jav...
 

Último

9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhidelhimodel235
 
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdfKohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdfManishSaxena95
 
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...asmaqueen5
 
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service DelhiCall Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhiasmaqueen5
 
Bridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdfBridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdfVickyAulakh1
 
SVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property BroadcastSVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property BroadcastSVN International Corp.
 
Rohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdfRohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdfabbu831446
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)delhi24hrs1
 
Kohinoor Hinjewadi Phase 2 Pune E-Brochure.pdf
Kohinoor Hinjewadi Phase 2 Pune  E-Brochure.pdfKohinoor Hinjewadi Phase 2 Pune  E-Brochure.pdf
Kohinoor Hinjewadi Phase 2 Pune E-Brochure.pdfManishSaxena95
 
Nyati Elite NIBM Road Pune E Brochure.pdf
Nyati Elite NIBM Road Pune E Brochure.pdfNyati Elite NIBM Road Pune E Brochure.pdf
Nyati Elite NIBM Road Pune E Brochure.pdfabbu831446
 
Yashwin Enchante Uppar Kharadi Pune E-Brochue.pdf
Yashwin Enchante Uppar Kharadi Pune  E-Brochue.pdfYashwin Enchante Uppar Kharadi Pune  E-Brochue.pdf
Yashwin Enchante Uppar Kharadi Pune E-Brochue.pdfManishSaxena95
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)delhi24hrs1
 
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhidelhimodel235
 
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...asmaqueen5
 
Kalpataru Exquisite Wakad Pune E-Brochure.pdf
Kalpataru Exquisite Wakad Pune  E-Brochure.pdfKalpataru Exquisite Wakad Pune  E-Brochure.pdf
Kalpataru Exquisite Wakad Pune E-Brochure.pdfManishSaxena95
 
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)Delhi Call girls
 
ACE Terra Yamuna Expressway | 8929888700
ACE Terra Yamuna Expressway | 8929888700ACE Terra Yamuna Expressway | 8929888700
ACE Terra Yamuna Expressway | 8929888700Truhomes
 
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)Delhi Call girls
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)Delhi Call girls
 

Último (20)

9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
 
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdfKohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdf
 
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
 
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service DelhiCall Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
 
Bridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdfBridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdf
 
SVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property BroadcastSVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property Broadcast
 
Rohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdfRohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdf
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Amar Colony (Delhi)
 
Kohinoor Hinjewadi Phase 2 Pune E-Brochure.pdf
Kohinoor Hinjewadi Phase 2 Pune  E-Brochure.pdfKohinoor Hinjewadi Phase 2 Pune  E-Brochure.pdf
Kohinoor Hinjewadi Phase 2 Pune E-Brochure.pdf
 
Nyati Elite NIBM Road Pune E Brochure.pdf
Nyati Elite NIBM Road Pune E Brochure.pdfNyati Elite NIBM Road Pune E Brochure.pdf
Nyati Elite NIBM Road Pune E Brochure.pdf
 
Yashwin Enchante Uppar Kharadi Pune E-Brochue.pdf
Yashwin Enchante Uppar Kharadi Pune  E-Brochue.pdfYashwin Enchante Uppar Kharadi Pune  E-Brochue.pdf
Yashwin Enchante Uppar Kharadi Pune E-Brochue.pdf
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Malviya Nagar(Delhi)
 
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
 
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
 
Kalpataru Exquisite Wakad Pune E-Brochure.pdf
Kalpataru Exquisite Wakad Pune  E-Brochure.pdfKalpataru Exquisite Wakad Pune  E-Brochure.pdf
Kalpataru Exquisite Wakad Pune E-Brochure.pdf
 
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
 
ACE Terra Yamuna Expressway | 8929888700
ACE Terra Yamuna Expressway | 8929888700ACE Terra Yamuna Expressway | 8929888700
ACE Terra Yamuna Expressway | 8929888700
 
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
 

Touchevents

  • 1. Hell is other browsers - Sartre The touch events Peter-Paul Koch (ppk) http://quirksmode.org http://twitter.com/ppk DIBI, 28 April 2010
  • 2. The desktop web Boring! - Only five browsers - with only one viewport each - that support nearly everything - Even IE? Yes, even IE.
  • 3.
  • 4. 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
  • 5. 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
  • 6. Before we start please open the following link on your iPhone or Android: http://quirksmode.org/touchevents It gives links to the test files.
  • 10. Keyboard users need different Mouse interaction than mouse users need different interactions than touch users. Your script accomodates all three modes, right? It's all a question of events.
  • 14. It's not an either-or proposition.
  • 15. It's not an either-or proposition. The Nokia E71 has a four-way navigation. Works like the arrow keys (including keycodes). But...
  • 16. It's not an either-or proposition. But... the “arrow keys” steer a mouse cursor. Key events and mouse events
  • 17. Today we'll concentrate on the touch events, though.
  • 18. Touch !== mouse - Area - Pressure - Temperature - more than one touch
  • 19. 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).
  • 20. dropdown.onmouseover = function (e) { // open dropdown dropdown.onmouseout = function (e) { // close dropdown // if appropriate dropdown.onmouseout = null } }
  • 21. http://quirksmode.org/touchevents Now open the second dropdown example. Task: Click on option 3.2 Doesn't work.
  • 22. dropdown.onmouseovertouchstart = function (e) { // open dropdown dropdown.onmouseouttouchend = function (e) { // close dropdown // if appropriate dropdown.onmouseout = null } } Not an entirely fair comparison.
  • 23. 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.
  • 24. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - All All iPhone, Android
  • 25. 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.)
  • 26. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 27. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 28. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 29. Interaction modes Mouse Keyboard Touch mousedown keydown touchstart mousemove keypress touchmove mouseup keyup touchend mouseover focus - mouseout blur - load, unload, click, submit, resize, zoom, change etc. etc.
  • 30. 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.
  • 31. 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.
  • 32. http://quirksmode.org/touchevents You can test the events for yourself at the touch action test page.
  • 34. 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.
  • 35. touchstart If a DOM change occurs mouseover onmouseover or mousemove onmousemove, the rest mousedown of the events is cancelled. mouseup (iPhone and Symbian) click :hover styles applied
  • 36. 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.
  • 37. element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } }
  • 38. 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.
  • 39. 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.
  • 40. element.onmousedown = function (e) { // initialise document.onmousemove = function (e) { // move } document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; } }
  • 41. 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?
  • 42. element.onmousedown = function (e) { document.onmousemove = etc. document.onmouseup = etc. } element.ontouchstart = function (e) { document.ontouchmove = etc. document.ontouchend = etc. }
  • 43. 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.
  • 44. 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.)
  • 45. 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.
  • 46. 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: ???
  • 47. Interaction modes - mouse - keyboard - touch - and a fourth....
  • 48. Interaction modes - mouse - keyboard - touch - trackball Generally fires a mousemove event
  • 49. Thank you! Questions? http://quirksmode.org http://twitter.com/ppk