$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Mobblestouch — W3C Touch Events and gestures
Search
Kornel Lesiński
October 25, 2011
Technology
2
730
Mobblestouch — W3C Touch Events and gestures
Presentation at Mr Mobbles Magical Emporium 10/2011
http://pornel.net/mobbles
Kornel Lesiński
October 25, 2011
Tweet
Share
More Decks by Kornel Lesiński
See All by Kornel Lesiński
SudWeb
kornel
0
210
Lossy PNG for true-color images (Velocity Conf EU 2014)
kornel
2
890
Modern PNG compressors
kornel
13
1.2k
Handling binary data in JS
kornel
1
400
Server-Sent Events
kornel
5
980
"HTML5" Transport Protocol
kornel
3
400
Front-end Performance
kornel
5
490
Other Decks in Technology
See All in Technology
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
210
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
760
Strands Agents × インタリーブ思考 で変わるAIエージェント設計 / Strands Agents x Interleaved Thinking AI Agents
takanorig
4
2k
AIBuildersDay_track_A_iidaxs
iidaxs
4
1.3k
『君の名は』と聞く君の名は。 / Your name, you who asks for mine.
nttcom
1
110
Snowflake導入から1年、LayerXのデータ活用の現在 / One Year into Snowflake: How LayerX Uses Data Today
civitaspo
0
2.3k
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
2
1.6k
AR Guitar: Expanding Guitar Performance from a Live House to Urban Space
ekito_station
0
150
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
Amazon Quick Suite で始める手軽な AI エージェント
shimy
1
1.8k
障害対応訓練、その前に
coconala_engineer
0
190
Next.js 16の新機能 Cache Components について
sutetotanuki
0
170
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
410
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
88
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
0
300
Prompt Engineering for Job Search
mfonobong
0
120
A Modern Web Designer's Workflow
chriscoyier
698
190k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
69
Getting science done with accelerated Python computing platforms
jacobtomlinson
0
76
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Reality Check: Gamification 10 Years Later
codingconduct
0
1.9k
Transcript
Mobblestouch
www.w3.org/TR/touch-events
Microsoft http://blogs.msdn.com/b/ie/archive/2011/10/19/ handling-multi-touch-and-mouse-input-in-all-browsers.aspx
mousedown = mousemove = mouseup = touchstart touchmove touchend
mouseover mouseout :hover
click
element.ontouchstart = function(event){…} element.addEventListener (‘touchstart’,…,…)
TouchEvent interface event.touches = […] event.chagedTouches = […]
TouchEvent interface event.pageX → event.touches[i].pageX event.target → event.touches[i].target event.targetTouches
Touch interface touch.pageY/touch.pageX touch.target touch.identifier
Div 1 Div 2 Div 3 mousedown mousemove mouseup
Div 1 Div 2 Div 3 touchstart touchmove touchend
Tap and… ontouchstart = function() { timer = setTimeout(hold, 1000)
} ontouchend = function() { clearTimeout(timer) if (!held) tap() } var timer; …hold!
Hold on! ontouchstart = function(e) { if (e.touches.length > 1)
return; clearTimeout(timer) timer = setTimeout(hold, 1000) e.preventDefault() }
call event.preventDefault()
body.ontouchmove = function(e) {e.preventDefault()}
:active trick body.ontouchmove = function(){}
gesturestart gestureend
1 2 Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) )
Zoom moves!
Math.atan2( (x-x),(y-y) )
Math.TAU = 2*Math.PI Math.atan2(…)/Math.TAU*360+180
Beware of CSS transforms order!
Swipe Slow = peek Fast = switch
Swipe event.timestamp
Device ✌ ✌ 2.x ” 3.x ✌ ? Emulator ✌
” ” None
Alt Alt + Shift
Phantom limb vodori.com/blog/phantom-limb.html
@media all and (-moz-touch-enabled:1) {…} if (ontouchstart in window) {…}
document.body.ontouchstart = function() { touch_enabled = true; } Detection
Trackpad ≠ Multitouch MozSwipeGesture XUL only MozMousePixelScroll onscroll event.wheelDeltaX/Y
@pornelski Image credits: Flickr—Vectorportal http://www.flickr.com/photos/ vectorportal, Flickr—Peter Kaminski http://flickr.com/people/peterkaminski, Denis-Carl
http://www.deniscarl.com, Failblog.com and Dailysquee.com. Presented at: Mr Mobbles Magical Emporium 10/2011