newHeight += diff;
}
if (width !== 0) {
- let magnetLeft = $this.linkeditor.utils.magnetize(newLeft, $this.magnetValuesX, newWidth);
+ let magnetLeft = $this.linkeditor.utils.magnetize(newLeft, $this.magnetValuesX, newWidth, true);
diff = newLeft - magnetLeft;
newWidth -= diff;
}
if (height !== 0) {
- let magnetTop = $this.linkeditor.utils.magnetize(newTop, $this.magnetValuesY, newHeight);
+ let magnetTop = $this.linkeditor.utils.magnetize(newTop, $this.magnetValuesY, newHeight, true);
diff = newTop - magnetTop;
newHeight -= diff;
}
return result;
},
- magnetize: function (value, values, width) {
+ magnetize: function (value, values, width, onlyCheckOtherSide) {
+ if (onlyCheckOtherSide === undefined) {
+ onlyCheckOtherSide = false;
+ }
if (width === undefined) {
width = 0;
}
for (let i in values) {
let v = values[i];
- let diff = Math.abs(v - value);
- let diffOtherSide = Math.abs(v - (value + width));
- if (diff < min) {
- min = diff;
- magnetValue = v;
- magnetizeOtherSide = false;
+
+ if (!onlyCheckOtherSide) {
+ let diff = Math.abs(v - value);
+ if (diff < min) {
+ min = diff;
+ magnetValue = v;
+ magnetizeOtherSide = false;
+ }
}
+
+ let diffOtherSide = Math.abs(v - (value + width));
if (diffOtherSide < min) {
min = diffOtherSide;
magnetValue = v;