[Libreoffice-commits] online.git: loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jul 24 18:04:22 UTC 2018
loleaflet/src/map/handler/Map.Tap.js | 65 ++++++++++++++---------------------
1 file changed, 26 insertions(+), 39 deletions(-)
New commits:
commit 03a29a169968a48064a190f40b68e111168d03f5
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Tue Jul 24 13:57:44 2018 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Tue Jul 24 14:03:10 2018 -0400
loleaflet: mobile: handle long click
Change-Id: I3c3ecce737e5c2457e922e2e612f0312dfab72dd
diff --git a/loleaflet/src/map/handler/Map.Tap.js b/loleaflet/src/map/handler/Map.Tap.js
index d5d25d570..b8a4e96a5 100644
--- a/loleaflet/src/map/handler/Map.Tap.js
+++ b/loleaflet/src/map/handler/Map.Tap.js
@@ -22,31 +22,21 @@ L.Map.Tap = L.Handler.extend({
L.DomEvent.preventDefault(e);
- this._fireClick = true;
-
// don't simulate click or track longpress if more than 1 touch
if (e.touches.length > 1) {
- this._fireClick = false;
clearTimeout(this._holdTimeout);
return;
}
- var first = e.touches[0],
- el = first.target;
+ var first = e.touches[0];
this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
- // if touching a link, highlight it
- if (el.tagName && el.tagName.toLowerCase() === 'a') {
- L.DomUtil.addClass(el, 'leaflet-active');
- }
-
// simulate long hold but setting a timeout
this._holdTimeout = setTimeout(L.bind(function () {
if (this._isTapValid()) {
- this._fireClick = false;
- this._onUp();
- this._simulateEvent('contextmenu', first);
+ this._fireDblClick = true;
+ this._onUp(e);
}
}, this), 1000);
@@ -66,21 +56,12 @@ L.Map.Tap = L.Handler.extend({
touchend: this._onUp
}, this);
- if (this._fireClick && e && e.changedTouches) {
-
- var first = e.changedTouches[0],
- el = first.target;
-
- if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
- L.DomUtil.removeClass(el, 'leaflet-active');
- }
+ var first = e.changedTouches[0];
+ this._simulateEvent('mouseup', first);
- this._simulateEvent('mouseup', first);
-
- // simulate click if the touch didn't move too much
- if (this._isTapValid()) {
- this._simulateEvent('click', first);
- }
+ if (this._fireDblClick) {
+ this._simulateEvent('dblclick', first);
+ this._fireDblClick = false;
}
},
@@ -91,21 +72,27 @@ L.Map.Tap = L.Handler.extend({
_onMove: function (e) {
var first = e.touches[0];
this._newPos = new L.Point(first.clientX, first.clientY);
+ this._simulateEvent('mousemove', first);
},
_simulateEvent: function (type, e) {
- var simulatedEvent = document.createEvent('MouseEvents');
-
- simulatedEvent._simulated = true;
- e.target._simulatedClick = true;
-
- simulatedEvent.initMouseEvent(
- type, true, true, window, 1,
- e.screenX, e.screenY,
- e.clientX, e.clientY,
- false, false, false, false, 0, null);
-
- e.target.dispatchEvent(simulatedEvent);
+ var simulatedEvent = {
+ type: type,
+ canBubble: false,
+ cancelable: true,
+ screenX: e.screenX,
+ screenY: e.screenY,
+ clientX: e.clientX,
+ clientY: e.clientY,
+ ctrlKey: false,
+ altKey: false,
+ shiftKey: false,
+ metaKey: false,
+ button: 0,
+ target: e.target,
+ preventDefault: function () {}
+ };
+ this._map._handleDOMEvent(simulatedEvent);
}
});
More information about the Libreoffice-commits
mailing list