lib/leaflet/src/dom/DomEvent.DoubleTap.js in leaflet-js-0.6.beta4 vs lib/leaflet/src/dom/DomEvent.DoubleTap.js in leaflet-js-0.7.0
- old
+ new
@@ -2,12 +2,12 @@
* Extends the event handling code with double tap support for mobile browsers.
*/
L.extend(L.DomEvent, {
- _touchstart: L.Browser.msTouch ? 'MSPointerDown' : 'touchstart',
- _touchend: L.Browser.msTouch ? 'MSPointerUp' : 'touchend',
+ _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
+ _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',
// inspired by Zepto touch code by Thomas Fuchs
addDoubleTapListener: function (obj, handler, id) {
var last,
doubleTap = false,
@@ -19,11 +19,11 @@
trackedTouches = [];
function onTouchStart(e) {
var count;
- if (L.Browser.msTouch) {
+ if (L.Browser.pointer) {
trackedTouches.push(e.pointerId);
count = trackedTouches.length;
} else {
count = e.touches.length;
}
@@ -38,20 +38,20 @@
doubleTap = (delta > 0 && delta <= delay);
last = now;
}
function onTouchEnd(e) {
- if (L.Browser.msTouch) {
+ if (L.Browser.pointer) {
var idx = trackedTouches.indexOf(e.pointerId);
if (idx === -1) {
return;
}
trackedTouches.splice(idx, 1);
}
if (doubleTap) {
- if (L.Browser.msTouch) {
+ if (L.Browser.pointer) {
// work around .type being readonly with MSPointer* events
var newTouch = { },
prop;
// jshint forin:false
@@ -71,32 +71,33 @@
}
}
obj[pre + touchstart + id] = onTouchStart;
obj[pre + touchend + id] = onTouchEnd;
- // on msTouch we need to listen on the document, otherwise a drag starting on the map and moving off screen
+ // on pointer we need to listen on the document, otherwise a drag starting on the map and moving off screen
// will not come through to us, so we will lose track of how many touches are ongoing
- var endElement = L.Browser.msTouch ? document.documentElement : obj;
+ var endElement = L.Browser.pointer ? document.documentElement : obj;
obj.addEventListener(touchstart, onTouchStart, false);
endElement.addEventListener(touchend, onTouchEnd, false);
- if (L.Browser.msTouch) {
- endElement.addEventListener('MSPointerCancel', onTouchEnd, false);
+ if (L.Browser.pointer) {
+ endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false);
}
return this;
},
removeDoubleTapListener: function (obj, id) {
var pre = '_leaflet_';
obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);
- (L.Browser.msTouch ? document.documentElement : obj).removeEventListener(
+ (L.Browser.pointer ? document.documentElement : obj).removeEventListener(
this._touchend, obj[pre + this._touchend + id], false);
- if (L.Browser.msTouch) {
- document.documentElement.removeEventListener('MSPointerCancel', obj[pre + this._touchend + id], false);
+ if (L.Browser.pointer) {
+ document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id],
+ false);
}
return this;
}
});