Created
September 8, 2014 14:15
-
-
Save redoPop/9050999cebcd7e50934a to your computer and use it in GitHub Desktop.
IE10 & IE11 don't trigger touch events (e.g., touchstart). If you want to differentiate touches from clicks, you must use the pointer events API and the event object's pointerType property:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onPointerDownHandler (event) { | |
if (event.pointerType === 'touch') { | |
// Equivalent to a touchstart on MS Surface | |
} | |
} | |
// For IE 10 | |
element.addEventListener('MSPointerDown', onPointerDownHandler); | |
// For IE 11+ | |
element.addEventListener('pointerdown', onPointerDownHandler); |
Chrome team has seen the light on Pointer API https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/ODWmcKNQl0I Safari and Firefox still dragging their feet
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MSDN docs on the change from IE10 to IE11 (i.e., dropping the vendor prefix):
http://msdn.microsoft.com/en-us/library/dn304886.aspx
General MSDN docs on Pointer Events:
http://msdn.microsoft.com/en-us/library/windows/apps/hh441233.aspx
It's also worth noting that peak IE10 use has already passed, and it's currently less popular than IEs 8, 9, or 11:
http://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0&qptimeframe=M
W3C candidate recommendation for pointer events:
http://www.w3.org/TR/pointerevents/
Cross-browser support for pointer events:
http://caniuse.com/#feat=pointer
And of course, a reminder that Chrome's developers are leaning towards supplementing the existing mouse and touch event APIs instead of implementing the pointer events API:
https://code.google.com/p/chromium/issues/detail?id=162757#c64