]> _ Git - fluidbook-toolbox.git/commitdiff
wip #4214 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 11 Oct 2022 08:09:29 +0000 (10:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 11 Oct 2022 08:09:29 +0000 (10:09 +0200)
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.links.js
resources/linkeditor/js/linkeditor.zoom.js

index ed5918e7d0a3a7ad55beabbc28608467a090afed..85fde75fb10055d45d46aed4e758afeac4ec9411 100644 (file)
@@ -64,7 +64,9 @@ LinkEditor.prototype = {
         // Disable scroll by spacebar
         $(window).on('keydown', function (e) {
             if (e.keyCode == 32) {
-                $("#linkeditor-main").addClass('grab');
+                if ($this.zoom.zoom !== 1) {
+                    $("#linkeditor-main").addClass('grab');
+                }
                 return false;
             } else if (e.keyCode == 18) {
                 $("#linkeditor-main").addClass('duplicate');
@@ -83,13 +85,14 @@ LinkEditor.prototype = {
         });
 
         $(document).on('mousedown', "#linkeditor-main", function (e) {
+            $this.setMouseCoordinates(e);
             if ($(this).hasClass('duplicate')) {
                 $this.links.duplicateLinkClick();
                 return;
             } else if ($(this).hasClass('grab') && $this.zoom.zoom > 1) {
-                $this.zoomdragging = {
-                    x: e.pageX,
-                    y: e.pageY,
+                $this.zoom.zoomdragging = {
+                    x: $this.mx,
+                    y: $this.my,
                     scrollX: $("#linkeditor-canvas").scrollLeft(),
                     scrollY: $("#linkeditor-canvas").scrollTop()
                 };
@@ -105,6 +108,7 @@ LinkEditor.prototype = {
         });
 
         $(window).on('mouseup', function (e) {
+            $this.setMouseCoordinates(e);
             $this.zoom.mouseUp();
             $this.rulers.mouseUp();
             $this.links.mouseUp();
@@ -213,8 +217,9 @@ LinkEditor.prototype = {
 
 
     updateMousePosition: function (e) {
-        this.mx = e.pageX;
-        this.my = e.pageY;
+        if (e !== undefined) {
+            this.setMouseCoordinates(e);
+        }
 
         this.rulers.updateMousePositionRulers();
         this.rulers.moveRuler();
@@ -223,6 +228,11 @@ LinkEditor.prototype = {
         this.zoom.updateMousePosition();
     },
 
+    setMouseCoordinates: function (e) {
+        this.mx = e.pageX;
+        this.my = e.pageY;
+    },
+
     changePage: function (page) {
         if (page === undefined) {
             let h = window.location.hash;
index be035a46bc1e4f2a3bd03f9fc116fde82069f35e..92eff378016ff440d1335440da5c3575f2b3fdb0 100644 (file)
@@ -383,7 +383,7 @@ LinkeditorLinks.prototype = {
 
     deleteSelection: function () {
         $(".link.selected").each(function () {
-            delete LINKS[$(this).data('uid')];
+            delete LINKS[$(this).attr('fb-uid')];
             $(this).remove();
         });
         this.linkeditor.hasChanged();
index ce1a00cfcb4717815c84cd3999847c6475367636..9deb85d331b59c880ba8bc42e80f0c436e08cd46 100644 (file)
@@ -11,6 +11,7 @@ LinkeditorZoom.prototype = {
         this.zoomdragging = false;
 
         $("#linkeditor-main").on('wheel', function (e) {
+            $this.linkeditor.setMouseCoordinates(e);
             let delta = e.originalEvent.deltaY;
             if (delta === 0) {
                 return true;
@@ -31,7 +32,7 @@ LinkeditorZoom.prototype = {
 
     mouseUp: function () {
         if (this.zoomdragging !== false) {
-            this.moveZoomDrag(e);
+            this.moveZoomDrag();
         }
         this.resetZoomDrag();
     },
@@ -41,7 +42,7 @@ LinkeditorZoom.prototype = {
             this.resetZoomDrag();
         }
         if (this.zoomdragging !== false) {
-            this.moveZoomDrag(e);
+            this.moveZoomDrag();
         }
     },
 
@@ -53,9 +54,9 @@ LinkeditorZoom.prototype = {
         this.zoomdragging = false;
     },
 
-    moveZoomDrag: function (e) {
-        let deltaX = e.pageX - this.zoomdragging.x;
-        let deltaY = e.pageY - this.zoomdragging.y;
+    moveZoomDrag: function () {
+        let deltaX = this.linkeditor.mx - this.zoomdragging.x;
+        let deltaY = this.linkeditor.my - this.zoomdragging.y;
         $("#linkeditor-canvas").scrollTo({
             top: this.zoomdragging.scrollY - deltaY, left: this.zoomdragging.scrollX - deltaX
         });