Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Mobblestouch — W3C Touch Events and gestures
Search
Kornel Lesiński
October 25, 2011
Technology
780
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Mobblestouch — W3C Touch Events and gestures
Presentation at Mr Mobbles Magical Emporium 10/2011
http://pornel.net/mobbles
Kornel Lesiński
October 25, 2011
Transcript
31 slides
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
More Decks by Kornel Lesiński
See All by Kornel Lesiński
SudWeb
kornel
0
290
Lossy PNG for true-color images (Velocity Conf EU 2014)
kornel
2
930
Modern PNG compressors
kornel
13
1.2k
Handling binary data in JS
kornel
1
440
Server-Sent Events
kornel
5
1k
"HTML5" Transport Protocol
kornel
3
450
Front-end Performance
kornel
5
550
Other Decks in Technology
See All in Technology
Fukurou Labo_Engineer_Deck
fukuroulabo
0
110
成長するID管理基盤における運用もコストも犠牲にしないオブザーバビリティ向上の実践 / Improving Observability for a Growing Identity Platform Without Adding Operational Burden or Cost
kaminashi
1
140
全てを疑え!非自明な挙動と異常系から考える堅牢なカスタムコントローラ開発入門(CNDW2026)
lycorptech_jp
PRO
0
120
OCI Artifact による自動運転タクシーに向けた OTA 基盤の構築
biwashi
1
300
Test Impact Analysis を武器に立ち向かう、AI 時代のテスト増加に対するヌーラボのアプローチ / getting-started-datadog-test-impact-analysis
k6s4i53rx
3
900
AI時代のTechLeadの問い〜Tech Lead Conference 2026 Autumn / questions-for-tech-leads-in-the-age-of-ai
haru860
0
100
AIフレンドリーなGenerative UIをJSXで
uhyo
2
850
FPGAでアクティブセンシングがやりたくてカメラモジュールを自作した話
ryuz88
0
140
Amazon Bedrock AgentCore の基礎とセキュリティ・ガバナンス
ren8k
0
290
フルTypeScript × AI駆動開発で開発量が数倍に (JSConf JP 2026 スポンサーLT:NCDC株式会社)
keitaibaraki
0
560
想定外の利用がプロダクトの価値を広げる
lycorptech_jp
PRO
0
130
AIエージェントのアーキテクチャ設計
nsatoh
0
590
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.5k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
300
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
590
Test your architecture with Archunit
thirion
2
2.5k
Everyday Curiosity
cassininazir
0
430
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
2
540
We Are The Robots
honzajavorek
0
470
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
910
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
GitHub's CSS Performance
jonrohan
1033
470k