mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Resize multiple elements (rectangles, diamonds and ellipses onl… (#1193)
* experiment resizing multiple elements * hack common component * calculate scale properly (still se only)fg * prioritize multi selection * take handle offset into calculation * fix master merge * refactor resizeElements out from App * wip: handlerRectanglesFromCoords * fix test with type assertion * properly show handles wip * revert previous one and do a tweak * remove unnecessary assignments * replace hack code with good one * refactor coords in arg * resize NW * resize from sw,ne * fix with setResizeHandle * do not show hint while resizing multiple elements * empty commit * fix format
This commit is contained in:
parent
b60f5fcf06
commit
2cc1105ff5
9 changed files with 808 additions and 510 deletions
|
@ -7,7 +7,9 @@ import { isLinearElement } from "./typeChecks";
|
|||
|
||||
// If the element is created from right to left, the width is going to be negative
|
||||
// This set of functions retrieves the absolute position of the 4 points.
|
||||
export function getElementAbsoluteCoords(element: ExcalidrawElement) {
|
||||
export function getElementAbsoluteCoords(
|
||||
element: ExcalidrawElement,
|
||||
): [number, number, number, number] {
|
||||
if (isLinearElement(element)) {
|
||||
return getLinearElementAbsoluteBounds(element);
|
||||
}
|
||||
|
@ -36,7 +38,7 @@ export function getDiamondPoints(element: ExcalidrawElement) {
|
|||
|
||||
export function getLinearElementAbsoluteBounds(
|
||||
element: ExcalidrawLinearElement,
|
||||
) {
|
||||
): [number, number, number, number] {
|
||||
if (element.points.length < 2 || !getShapeForElement(element)) {
|
||||
const { minX, minY, maxX, maxY } = element.points.reduce(
|
||||
(limits, [x, y]) => {
|
||||
|
@ -186,7 +188,9 @@ export function getArrowPoints(
|
|||
return [x2, y2, x3, y3, x4, y4];
|
||||
}
|
||||
|
||||
export function getCommonBounds(elements: readonly ExcalidrawElement[]) {
|
||||
export function getCommonBounds(
|
||||
elements: readonly ExcalidrawElement[],
|
||||
): [number, number, number, number] {
|
||||
if (!elements.length) {
|
||||
return [0, 0, 0, 0];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue