Skip to content

Commit

Permalink
Touch ie fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akoppela committed Apr 26, 2011
1 parent b7347ba commit 2b6528c
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions Source/Browser/Features.Touch.js
Expand Up @@ -16,35 +16,37 @@ provides: Browser.Features.Touch
...
*/

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;
})();
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;
})();
};

0 comments on commit 2b6528c

Please sign in to comment.