[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-3' - loleaflet/src

Mihai Varga mihai.varga at collabora.com
Wed Jul 8 09:43:47 PDT 2015


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

New commits:
commit c19c7e305353a5536103f4157c7ddbab04586edf
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 dad1cea..0f97438 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -742,29 +742,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