feat: vertical align for labelled arrows
This commit is contained in:
parent
da8dd389a9
commit
66ccc254f0
@ -40,7 +40,11 @@ import { isBindingElement } from "./typeChecks";
|
|||||||
import { shouldRotateWithDiscreteAngle } from "../keys";
|
import { shouldRotateWithDiscreteAngle } from "../keys";
|
||||||
import { getBoundTextElement, handleBindTextResize } from "./textElement";
|
import { getBoundTextElement, handleBindTextResize } from "./textElement";
|
||||||
import { getShapeForElement } from "../renderer/renderElement";
|
import { getShapeForElement } from "../renderer/renderElement";
|
||||||
import { DRAGGING_THRESHOLD } from "../constants";
|
import {
|
||||||
|
BOUND_TEXT_PADDING,
|
||||||
|
DRAGGING_THRESHOLD,
|
||||||
|
VERTICAL_ALIGN,
|
||||||
|
} from "../constants";
|
||||||
import { Mutable } from "../utility-types";
|
import { Mutable } from "../utility-types";
|
||||||
|
|
||||||
const editorMidPointsCache: {
|
const editorMidPointsCache: {
|
||||||
@ -1304,6 +1308,16 @@ export class LinearElementEditor {
|
|||||||
}
|
}
|
||||||
x = midSegmentMidpoint[0] - boundTextElement.width / 2;
|
x = midSegmentMidpoint[0] - boundTextElement.width / 2;
|
||||||
y = midSegmentMidpoint[1] - boundTextElement.height / 2;
|
y = midSegmentMidpoint[1] - boundTextElement.height / 2;
|
||||||
|
if (element.points.length === 2) {
|
||||||
|
if (boundTextElement.verticalAlign === VERTICAL_ALIGN.TOP) {
|
||||||
|
y =
|
||||||
|
midSegmentMidpoint[1] -
|
||||||
|
boundTextElement.height -
|
||||||
|
BOUND_TEXT_PADDING * 2;
|
||||||
|
} else if (boundTextElement.verticalAlign === VERTICAL_ALIGN.BOTTOM) {
|
||||||
|
y = midSegmentMidpoint[1] + BOUND_TEXT_PADDING * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { x, y };
|
return { x, y };
|
||||||
};
|
};
|
||||||
|
@ -793,7 +793,11 @@ export const shouldAllowVerticalAlign = (
|
|||||||
const hasBoundContainer = isBoundToContainer(element);
|
const hasBoundContainer = isBoundToContainer(element);
|
||||||
if (hasBoundContainer) {
|
if (hasBoundContainer) {
|
||||||
const container = getContainerElement(element);
|
const container = getContainerElement(element);
|
||||||
if (isTextElement(element) && isArrowElement(container)) {
|
if (
|
||||||
|
isTextElement(element) &&
|
||||||
|
isArrowElement(container) &&
|
||||||
|
container.points.length > 2
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user