loleaflet/src/control/Control.LokDialog.js |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 4bf256d4cb1d3c711a82d33aeedad9ca0d31fa70
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Mon May 20 16:55:02 2019 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu May 23 15:19:44 2019 +0200

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

diff --git a/loleaflet/src/control/Control.LokDialog.js 
b/loleaflet/src/control/Control.LokDialog.js
index 3ecb68773..d2907f5b9 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);
@@ -666,7 +676,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 }));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to