]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5817 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Mar 2023 16:09:55 +0000 (17:09 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Mar 2023 16:09:55 +0000 (17:09 +0100)
resources/linkeditor/js/linkeditor.links.js

index fa58c1dd41e1c82bf360cd78dd3429ed28014d42..728f546dc7937cab1e8e82fe96d6ffacabe248e3 100644 (file)
@@ -750,32 +750,39 @@ LinkeditorLinks.prototype = {
 
     loadLinks: function (page, side) {
         let $this = this;
+        this.normalizeLinksPage();
         $.each(LINKS, function (uid, link) {
             if ($('#linkeditor-links [fb-uid="' + uid + '"]').length > 0) {
                 return;
             }
-            link.left = parseFloat(link.left)
-            if (!$this.linkeditor.single) {
-                if (page % 2 === 1 && link.page % 2 === 0 && link.left > $this.linkeditor.pw) {
-                    link.page++;
-                    link.left -= $this.linkeditor.pw;
-                }
-                if (side === 'right' && link.page % 2 === 1) {
-                    link.page--;
-                    link.left += $this.linkeditor.pw;
-                }
-            }
-
             if (link.page != page) {
                 return;
             }
-            console.log(link);
             $this.addLink(link, false);
         });
         this.updateLayers();
         this.linkeditor.undo.initState();
     },
 
+    normalizeLinksPage() {
+        let pw = this.linkeditor.pw;
+        let single = this.linkeditor.single;
+        $.each(LINKS, function (uid, link) {
+            link.left = parseFloat(link.left)
+            if (!single) {
+                if (link.page % 2 === 0 && link.left > pw) {
+                    link.page++;
+                    link.left -= pw;
+                }
+                if (link.page % 2 === 1) {
+                    link.page--;
+                    link.left += pw;
+                }
+            }
+            LINKS[uid] = link;
+        });
+    },
+
 
     addLink: function (link, triggerChange) {
         if (triggerChange === undefined) {