Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Work around Safari touch-listener bug
Browse files Browse the repository at this point in the history
Related to #33
  • Loading branch information
dfreedm committed Aug 5, 2014
1 parent eb3663f commit 43ea4dc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/platform-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@
*/
(function(scope) {
var dispatcher = scope.dispatcher;
var nav = window.navigator;

if (window.PointerEvent) {
dispatcher.registerSource('pointer', scope.pointerEvents);
} else if (window.navigator.msPointerEnabled) {
} else if (nav.msPointerEnabled) {
dispatcher.registerSource('ms', scope.msEvents);
} else {
dispatcher.registerSource('mouse', scope.mouseEvents);
if (window.ontouchstart !== undefined) {
dispatcher.registerSource('touch', scope.touchEvents);
/*
* NOTE: an empty touch listener on body will reactivate nodes imported from templates with touch listeners
* Removing it will re-break the nodes
*
* Work around for https://bugs.webkit.org/show_bug.cgi?id=135628
*/
var isSafari = nav.userAgent.match('Safari') && !nav.userAgent.match('Chrome');
if (isSafari) {
document.body.addEventListener('touchstart', function(){});
}
}
}

Expand Down

0 comments on commit 43ea4dc

Please sign in to comment.