Created
April 24, 2011 13:25
-
-
Save akoppela/939547 to your computer and use it in GitHub Desktop.
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
if(!Browser.ie){ | |
Browser.Features.Touch = (function(){ | |
try { | |
document.createEvent('TouchEvent').initTouchEvent('touchstart'); | |
return true; | |
} catch (exception){} | |
return false; | |
})(); | |
// Chrome 5 thinks it is touchy! | |
// Android doesn't have a touch delay and dispatchEvent does not fire the handler | |
Browser.Features.iOSTouch = (function(){ | |
var name = 'cantouch', // Name does not matter | |
html = document.html, | |
hasTouch = false; | |
var handler = function(){ | |
html.removeEventListener(name, handler, true); | |
hasTouch = true; | |
}; | |
try { | |
html.addEventListener(name, handler, true); | |
var event = document.createEvent('TouchEvent'); | |
event.initTouchEvent(name); | |
html.dispatchEvent(event); | |
return hasTouch; | |
} catch (exception){} | |
handler(); // Remove listener | |
return false; | |
})(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment