From: Vincent Vanwaelscappel Date: Tue, 21 Mar 2023 16:09:55 +0000 (+0100) Subject: wip #5817 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=96485fcc94d26aab19b9f36776ec8980733fa184;p=fluidbook-toolbox.git wip #5817 @0.5 --- diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index fa58c1dd4..728f546dc 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -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) {