Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
760
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
More Decks by Kornel Lesiński
See All by Kornel Lesiński
SudWeb
kornel
0
260
Lossy PNG for true-color images (Velocity Conf EU 2014)
kornel
2
920
Modern PNG compressors
kornel
13
1.2k
Handling binary data in JS
kornel
1
420
Server-Sent Events
kornel
5
1k
"HTML5" Transport Protocol
kornel
3
430
Front-end Performance
kornel
5
530
Other Decks in Technology
See All in Technology
作る力から、見極める力へ — AI時代に広がるエンジニアの価値と役割
rince
0
340
ロボティクスの技術 / Robotics Technology
ks91
PRO
0
130
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
320
AWS Security Hub CSPMの成功・失敗体験
cmusudakeisuke
0
560
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
200
Deep Data Security 機能解説
oracle4engineer
PRO
2
120
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
430
2026年6月23日 Syncable Tech + Start Python Club にて
hamukazu
0
150
5分でわかるDuckDB Quack
chanyou0311
3
250
レガシーな広告配信システムでのAI駆動開発/運用の挑戦
i16fujimoto
0
120
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
140
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
320
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
RailsConf 2023
tenderlove
30
1.5k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
480
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Facilitating Awesome Meetings
lara
57
7k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Unsuck your backbone
ammeep
672
58k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
How GitHub (no longer) Works
holman
316
150k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
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