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
750
2
Share
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
240
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
420
Front-end Performance
kornel
5
520
Other Decks in Technology
See All in Technology
業務に残された「良くない型」で考える「TypeScriptの難しさ」
sajikix
1
380
AI飲み会幹事エージェントを作っただけなのに
ykimi
0
230
写真で見るAWS Summit Singapore 2026
k_adachi_01
0
120
ワールドカフェ再び、そしてゴール・ルール・ロール・ツール / World Café Revisited, and the Goals-Rules-Roles-Tools
ks91
PRO
0
180
freeeで運用しているAIQAについて
qatonchan
1
640
Terragrunt x Snowflake + dbt で作るマルチテナントなデータ基盤構築プラットフォーム
gak_t12
0
430
全社統制を維持しながら現場負担をどう減らすか〜プラットフォームチームとセキュリティチームで進めたSecurity Hub活用によるAWS統制の見直し〜/secjaws-security-hub-custom-insights
mhrtech
1
560
20260515 OpenIDファウンデーション・ジャパンご紹介
oidfj
0
160
20260515 ⾃分のアカウントとプライバシーを守る認証と認可の話〜利⽤者向け〜
oidfj
0
710
開発サイクルのボーダーレス化に伴う組織変革から学んだこと / Organizational Transformation Amid the Borderless Development Cycle
mii3king
0
210
オライリーイベント登壇資料「鉄リサイクル・産廃業界におけるAI技術実応用のカタチ」
takarasawa_
0
410
Fラン学生が考える、AI時代のデザインに執着した突破口
husengs7
1
210
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.2k
Amusing Abliteration
ianozsvald
1
170
Embracing the Ebb and Flow
colly
88
5k
Discover your Explorer Soul
emna__ayadi
2
1.1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Typedesign – Prime Four
hannesfritz
42
3k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
270
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
360
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