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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu May 23 13:08:24 UTC 2019


 loleaflet/src/control/Control.LokDialog.js |   50 ++++++++++++++++-------------
 1 file changed, 29 insertions(+), 21 deletions(-)

New commits:
commit 17dc46dcd166698769afaa69ffa2ddcf3c46be6d
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon May 20 16:55:02 2019 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu May 23 15:08:14 2019 +0200

    Constraints for dialogs moving
    
    Change-Id: If489126659684cd99f2a153135cb2c05b9312c02
    Reviewed-on: https://gerrit.libreoffice.org/72855
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 370277afb..b2502d175 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -58,9 +58,19 @@ L.Control.LokDialog = L.Control.extend({
 		var target = findZoomTarget(id);
 
 		if (target) {
+			var newX = target.initialState.startX + ev.deltaX;
+			var newY = target.initialState.startY + ev.deltaY;
+
+			// Don't allow to put dialog outside the view
+			if (window.mode.isDesktop() &&
+				(newX < -target.width/2 || newY < -target.height/2
+				|| newX > window.innerWidth - target.width/2
+				|| newY > window.innerHeight - target.height/2))
+				return;
+
 			target.transformation.translate = {
-				x: target.initialState.startX + ev.deltaX,
-				y: target.initialState.startY + ev.deltaY
+				x: newX,
+				y: newY
 			};
 
 			updateTransformation(target);
@@ -522,7 +532,7 @@ L.Control.LokDialog = L.Control.extend({
 			removeZoomTarget(targetId);
 		}
 
-		zoomTargets.push({key: targetId, value: zoomTarget, transformation: transformation, initialState: state});
+		zoomTargets.push({key: targetId, value: zoomTarget, transformation: transformation, initialState: state, width:width, height: height});
 
 		var hammerAll = new Hammer(canvas);
 		hammerAll.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
commit 5dc20e98d73cabecab34eeedda5648e4edb6b28d
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon May 20 15:31:53 2019 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu May 23 15:08:06 2019 +0200

    Allow to use pan gesture on desktop
    
    Change-Id: Ifbc6102407add31f63b1be0173c5c8eeb3e8e2db
    Reviewed-on: https://gerrit.libreoffice.org/72854
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 072ae72b5..370277afb 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -524,24 +524,22 @@ L.Control.LokDialog = L.Control.extend({
 
 		zoomTargets.push({key: targetId, value: zoomTarget, transformation: transformation, initialState: state});
 
-		if (window.mode.isMobile() || window.mode.isTablet()) {
-			var hammerAll = new Hammer(canvas);
-			hammerAll.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
-			hammerAll.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith([hammerAll.get('pan')]);
-
-			hammerAll.on('panstart panmove', this.onPan);
-			hammerAll.on('pinchstart pinchmove', this.onPinch);
-			hammerAll.on('hammer.input', function(ev) {
-				if (ev.isFinal) {
-					var id = toZoomTargetId(ev.target.id);
-					var target = findZoomTarget(id);
-					if (target) {
-						target.initialState.startX = target.transformation.translate.x;
-						target.initialState.startY = target.transformation.translate.y;
-					}
+		var hammerAll = new Hammer(canvas);
+		hammerAll.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
+		hammerAll.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith([hammerAll.get('pan')]);
+
+		hammerAll.on('panstart panmove', this.onPan);
+		hammerAll.on('pinchstart pinchmove', this.onPinch);
+		hammerAll.on('hammer.input', function(ev) {
+			if (ev.isFinal) {
+				var id = toZoomTargetId(ev.target.id);
+				var target = findZoomTarget(id);
+				if (target) {
+					target.initialState.startX = target.transformation.translate.x;
+					target.initialState.startY = target.transformation.translate.y;
 				}
-			});
-		}
+			}
+		});
 
 		updateTransformation(findZoomTarget(targetId));
 	},


More information about the Libreoffice-commits mailing list