From 5843bdaa3ef4127689a2b1615d7021f590636e19 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 23 Feb 2023 16:26:44 +0100 Subject: [PATCH] wait #5751 @1 --- resources/linkeditor/js/linkeditor.links.js | 32 +++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index 9c59fef31..d018d33ce 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -52,7 +52,6 @@ LinkeditorLinks.prototype = { selectLink = false; } else { selectLink = true; - deselectAll = true; } } if (deselectAll) { @@ -606,22 +605,39 @@ LinkeditorLinks.prototype = { return; } - let magnet = !key.ctrl && $(".link.selected").length === 1; + let magnet = !key.ctrl; let $this = this; let f = 1 / (this.linkeditor.fs * this.linkeditor.zoom.zoom); let dx = (this.linkeditor.mx - this.dragLinkPos.x) * f; let dy = (this.linkeditor.my - this.dragLinkPos.y) * f; + var rect = {left: 10000000, top: 10000000, right: 0, bottom: 0}; + + if (magnet) { + $(".link.selected").each(function () { + let left = $(this).data('drag-orig-left') + dx; + let top = $(this).data('drag-orig-top') + dy; + let right = left + $(this).data('drag-orig-width'); + let bottom = top + $(this).data('drag-orig-height'); + + rect.left = Math.min(left, rect.left); + rect.right = Math.max(right, rect.right); + rect.top = Math.min(top, rect.top); + rect.bottom = Math.max(bottom, rect.bottom); + }); + + let rx = $this.linkeditor.utils.magnetize(rect.left, $this.magnetValuesX, rect.right - rect.left) + let ry = $this.linkeditor.utils.magnetize(rect.top, $this.magnetValuesY, rect.bottom - rect.top); + + dx -= rect.left - rx; + dy -= rect.top - ry; + } + + $(".link.selected").each(function () { let left = $(this).data('drag-orig-left') + dx; let top = $(this).data('drag-orig-top') + dy; - // Magnets are enabled when ctrl is not pressed and there is only one item in the selection - if (magnet) { - left = $this.linkeditor.utils.magnetize(left, $this.magnetValuesX, $(this).data('drag-orig-width')); - top = $this.linkeditor.utils.magnetize(top, $this.magnetValuesY, $(this).data('drag-orig-height')); - } - $(this) .attr('fb-left', left) .attr('fb-top', top) -- 2.39.5