fix: Clear up element dragging & binding
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
@@ -21,7 +21,7 @@ import { getPerfectElementSize } from "./sizeHelpers";
|
|||||||
import { getBoundTextElement } from "./textElement";
|
import { getBoundTextElement } from "./textElement";
|
||||||
import { getMinTextElementWidth } from "./textMeasurements";
|
import { getMinTextElementWidth } from "./textMeasurements";
|
||||||
import {
|
import {
|
||||||
isArrowElement,
|
isArrowElement as isBindingElement,
|
||||||
isElbowArrow,
|
isElbowArrow,
|
||||||
isFrameLikeElement,
|
isFrameLikeElement,
|
||||||
isImageElement,
|
isImageElement,
|
||||||
@@ -108,19 +108,7 @@ export const dragSelectedElements = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
elementsToUpdate.forEach((element) => {
|
elementsToUpdate.forEach((element) => {
|
||||||
const isArrow = !isArrowElement(element);
|
if (!isBindingElement(element)) {
|
||||||
const isStartBoundElementSelected =
|
|
||||||
isArrow ||
|
|
||||||
(element.startBinding
|
|
||||||
? elementsToUpdateIds.has(element.startBinding.elementId)
|
|
||||||
: false);
|
|
||||||
const isEndBoundElementSelected =
|
|
||||||
isArrow ||
|
|
||||||
(element.endBinding
|
|
||||||
? elementsToUpdateIds.has(element.endBinding.elementId)
|
|
||||||
: false);
|
|
||||||
|
|
||||||
if (!isArrowElement(element)) {
|
|
||||||
updateElementCoords(pointerDownState, element, scene, adjustedOffset);
|
updateElementCoords(pointerDownState, element, scene, adjustedOffset);
|
||||||
|
|
||||||
// skip arrow labels since we calculate its position during render
|
// skip arrow labels since we calculate its position during render
|
||||||
@@ -143,7 +131,6 @@ export const dragSelectedElements = (
|
|||||||
// NOTE: Add a little initial drag to the arrow dragging when the arrow
|
// NOTE: Add a little initial drag to the arrow dragging when the arrow
|
||||||
// is the single element being dragged to avoid accidentally unbinding
|
// is the single element being dragged to avoid accidentally unbinding
|
||||||
// the arrow when the user just wants to select it.
|
// the arrow when the user just wants to select it.
|
||||||
|
|
||||||
elementsToUpdate.size > 1 ||
|
elementsToUpdate.size > 1 ||
|
||||||
Math.max(Math.abs(adjustedOffset.x), Math.abs(adjustedOffset.y)) >
|
Math.max(Math.abs(adjustedOffset.x), Math.abs(adjustedOffset.y)) >
|
||||||
DRAGGING_THRESHOLD ||
|
DRAGGING_THRESHOLD ||
|
||||||
@@ -151,9 +138,12 @@ export const dragSelectedElements = (
|
|||||||
) {
|
) {
|
||||||
updateElementCoords(pointerDownState, element, scene, adjustedOffset);
|
updateElementCoords(pointerDownState, element, scene, adjustedOffset);
|
||||||
|
|
||||||
const shouldUnbindStart =
|
const shouldUnbindStart = element.startBinding
|
||||||
element.startBinding && !isStartBoundElementSelected;
|
? !elementsToUpdateIds.has(element.startBinding.elementId)
|
||||||
const shouldUnbindEnd = element.endBinding && !isEndBoundElementSelected;
|
: true;
|
||||||
|
const shouldUnbindEnd = element.endBinding
|
||||||
|
? !elementsToUpdateIds.has(element.endBinding.elementId)
|
||||||
|
: true;
|
||||||
if (shouldUnbindStart || shouldUnbindEnd) {
|
if (shouldUnbindStart || shouldUnbindEnd) {
|
||||||
// NOTE: Moving the bound arrow should unbind it, otherwise we would
|
// NOTE: Moving the bound arrow should unbind it, otherwise we would
|
||||||
// have weird situations, like 0 lenght arrow when the user moves
|
// have weird situations, like 0 lenght arrow when the user moves
|
||||||
|
|||||||
Reference in New Issue
Block a user