selectLink = false;
} else {
selectLink = true;
- deselectAll = true;
}
}
if (deselectAll) {
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)