[Libreoffice-commits] online.git: loleaflet/src

Mihai Varga mihai.varga at collabora.com
Tue Jul 7 09:21:50 PDT 2015


 loleaflet/src/layer/tile/TileLayer.js |   38 +++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 16 deletions(-)

New commits:
commit fea50859b9f4a8ce2e769b1199fb314c9afe1eeb
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Tue Jul 7 19:20:22 2015 +0300

    loleaflet: send click event before doubleclick
    
    Also, the click event is now fired instantly, previously we would've
    waited 250ms to see if a dblclick occurs and we would cancel the first
    2 clicks

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 37bbe44..7f4b843 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -747,29 +747,35 @@ L.TileLayer = L.GridLayer.extend({
 				clearTimeout(this._holdMouseEvent);
 				this._holdMouseEvent = null;
 			}
-			if (this._mouseEventsQueue.length === 3) {
-				// i.e. we have mousedown, mouseup, mousedown and here comes another
-				// mouseup. Those are 2 consecutive clicks == doubleclick, we cancel
-				// everything and wait for the dblclick event to arrive where it's handled
+			if (this._clickTime && Date.now() - this._clickTime <= 250) {
+				// double click, a click was sent already
+				this._mouseEventsQueue = [];
+				return;
+			}
+			else {
+				// if it's a click or mouseup after selecting
+				if (this._mouseEventsQueue.length > 0 || this._editMode) {
+					this._clickTime = Date.now();
+					if (this._mouseEventsQueue.length > 0) {
+						// fire mousedown
+						this._mouseEventsQueue[0]();
+					}
+					this._mouseEventsQueue = [];
+				}
 				if (!this._editMode) {
 					this._editMode = true;
 					this._map.fire('updatemode:edit');
 				}
-				this._mouseEventsQueue = [];
-				return;
-			}
-			mousePos = this._latLngToTwips(e.latlng);
-			this._mouseEventsQueue.push(L.bind(function() {
+				mousePos = this._latLngToTwips(e.latlng);
 				this._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1);
 				this._textArea.focus();
-			}, this));
-			this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), 250);
 
-			if (this._startMarker._icon) {
-				L.DomUtil.removeClass(this._startMarker._icon, 'leaflet-not-clickable');
-			}
-			if (this._endMarker._icon) {
-				L.DomUtil.removeClass(this._endMarker._icon, 'leaflet-not-clickable');
+				if (this._startMarker._icon) {
+					L.DomUtil.removeClass(this._startMarker._icon, 'leaflet-not-clickable');
+				}
+				if (this._endMarker._icon) {
+					L.DomUtil.removeClass(this._endMarker._icon, 'leaflet-not-clickable');
+				}
 			}
 		}
 		else if (e.type === 'mousemove' && this._mouseDown) {


More information about the Libreoffice-commits mailing list