diff --git a/src/core/Browser.js b/src/core/Browser.js index f0ae4b57..36906fb9 100644 --- a/src/core/Browser.js +++ b/src/core/Browser.js @@ -22,6 +22,31 @@ mobileOpera: mobile && opera, mobile: mobile, - touch: ('ontouchstart' in document.documentElement) + touch: (function() { + var touchSupported = false;; + + // WebKit, etc + if ('ontouchstart' in document.documentElement) { + return true; + } + + // Firefox/Gecko + var e = document.createElement('div'); + + // If no support for basic event stuff, unlikely to have touch support + if (!e.setAttribute || !e.removeAttribute) { + return false; + } + + e.setAttribute('ontouchstart', 'return;'); + if (typeof e['ontouchstart'] == 'function') { + touchSupported = true; + } + + e.removeAttribute('ontouchstart'); + e = null; + + return touchSupported; + })() }; -})(); \ No newline at end of file +})(); diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js index 9b1bc9a2..8d0f42d9 100644 --- a/src/dom/Draggable.js +++ b/src/dom/Draggable.js @@ -30,7 +30,7 @@ L.Draggable = L.Class.extend({ }, _onDown: function(e) { - if (e.shiftKey || ((e.which != 1) && (e.button != 1) && !e.touches)) { return; } + if ((!L.Browser.touch && e.shiftKey) || ((e.which != 1) && (e.button != 1) && !e.touches)) { return; } if (e.touches && e.touches.length > 1) { return; }