Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Elbow arrow segment fixing & positioning #8952

Merged
merged 300 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
4933511
Fixed point delete
mtolmacs Oct 24, 2024
48e55d4
Mark fixed segment midpoint with hollow handle
mtolmacs Oct 24, 2024
42a9b22
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Oct 27, 2024
5f81c9d
Fixed, grid snapping
mtolmacs Oct 27, 2024
85f900b
Multi fixed element w/ rendering error
mtolmacs Oct 27, 2024
88d1115
Comparison fix attempt
mtolmacs Oct 27, 2024
5edf992
Testing simplified point translation
mtolmacs Oct 28, 2024
f0b864e
Segment direction and render fix
mtolmacs Oct 28, 2024
83a7341
Fixed multi segment drag
mtolmacs Oct 28, 2024
67d21f2
Fix paste
mtolmacs Oct 28, 2024
91966ff
Fix lint
mtolmacs Oct 28, 2024
47ba905
Optimize frame highlight state change, fix recursive state change war…
mtolmacs Oct 28, 2024
ba6f730
Allow proper dragging
mtolmacs Oct 28, 2024
24760ce
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Oct 30, 2024
3965542
Midpoints rendering for elbow arrows ignoring pre-cached ones
mtolmacs Oct 30, 2024
9aea5c2
Hook detection
mtolmacs Oct 30, 2024
3006312
Broken but refactor is needed going forward
mtolmacs Oct 31, 2024
6aef677
Fix midpoint repositioning on some configurations
mtolmacs Nov 1, 2024
4531395
Fix segment jump in some configuration due to binding code
mtolmacs Nov 1, 2024
f6210b6
Unified anchor and heading
mtolmacs Nov 1, 2024
10172ce
More stable midpoint heading selection
mtolmacs Nov 1, 2024
ce2b540
Fix lint
mtolmacs Nov 1, 2024
c5914a5
More fixes
mtolmacs Nov 1, 2024
c76f805
Merge branch 'feat/elbow-arrow-movable-segments' of github.com:excali…
mtolmacs Nov 1, 2024
5c0b9f5
fix: load font faces in Safari manually (#8693)
Mrazator Oct 30, 2024
949f2dd
fix: fix trailing line whitespaces layout shift (#8714)
Mrazator Oct 30, 2024
2664b30
chore: simplify line-break regexes, separate text wrapping (#8715)
Mrazator Oct 30, 2024
f784545
Refining horizontal fixed segments
mtolmacs Nov 1, 2024
c8bf645
Simpler approach to remove hooks
mtolmacs Nov 3, 2024
7b3f607
Fix midpoint hit issue
mtolmacs Nov 4, 2024
df0cea6
Fix randomly jumping multi-fixed segments
mtolmacs Nov 4, 2024
07ce36a
Revert font fix
mtolmacs Nov 4, 2024
77d96bd
Revert explicit active marker for some events
mtolmacs Nov 4, 2024
d699e7d
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Nov 4, 2024
433dafe
Remove explicit active handler
mtolmacs Nov 4, 2024
a6ec3d1
Remove empty line
mtolmacs Nov 4, 2024
ab6bcaa
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Nov 5, 2024
aa661b8
Fix knot in elbow arrows
mtolmacs Nov 5, 2024
d19c679
Deep compare memoization, jest extension for point comparison, basic …
mtolmacs Nov 5, 2024
4d48cd5
Revert state change excess fix for another PR
mtolmacs Nov 5, 2024
e313bc8
Optimize elbow arrow point generation with memoization
mtolmacs Nov 7, 2024
e134dda
Refactor arrow type change action to fix inaccessible midpoint move
mtolmacs Nov 7, 2024
1ae8168
Add comment to trigger CI again
mtolmacs Nov 7, 2024
5414817
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Nov 11, 2024
6538baa
Short segment is not consistently handled
mtolmacs Nov 11, 2024
1f9e854
Fix unselect
mtolmacs Nov 11, 2024
076377f
Fix stale midpoint cache after midpoint delete
mtolmacs Nov 11, 2024
b3123ef
Double click adds label to elbow arrows
mtolmacs Nov 11, 2024
9f1084f
Update midpoint segment cache after scene restore
mtolmacs Nov 11, 2024
45a8c03
Remove unneeded type import
mtolmacs Nov 11, 2024
3752c39
First and last midpoints are fixable
mtolmacs Nov 12, 2024
b55c6a7
Simplify flip action
mtolmacs Nov 13, 2024
1ff89d0
Fix lint
mtolmacs Nov 13, 2024
fc9b574
Fix flipping
mtolmacs Nov 13, 2024
92a61b3
Fix lint
mtolmacs Nov 13, 2024
b3d35f3
Drag cloning elbow arrows
mtolmacs Nov 13, 2024
5409e9e
Fix fixed segment removal
mtolmacs Nov 13, 2024
6d658e1
Duplication action fix
mtolmacs Nov 13, 2024
22971c0
Broken multi-fixed segments
mtolmacs Nov 14, 2024
ca2396d
Revert "Broken multi-fixed segments"
mtolmacs Nov 16, 2024
a8c13a3
Simpler calc
mtolmacs Nov 17, 2024
dfbee40
fix: usage of `node12 which is deprecated` (#8791)
hamirmahal Nov 11, 2024
1f6d2ff
fix: cleanup scripts and support upto node 22 (#8794)
ad1992 Nov 11, 2024
635cb1d
Fix simplification ordering issue
mtolmacs Nov 18, 2024
1e8c76b
Small refactor
mtolmacs Nov 18, 2024
a8e4830
New approach
mtolmacs Nov 18, 2024
cab7653
anchor to segment differently
mtolmacs Nov 19, 2024
d443dc2
Start/end fix fix
mtolmacs Nov 19, 2024
5cae7ed
End fix fix
mtolmacs Nov 19, 2024
88f37bc
Reduce minimum segment removal distance
mtolmacs Nov 19, 2024
907307a
Fix lint
mtolmacs Nov 19, 2024
afcadb1
Test fixes
mtolmacs Nov 19, 2024
79bfd58
Lint fix
mtolmacs Nov 19, 2024
c897406
Fix midpoint click misses
mtolmacs Nov 20, 2024
e3d773a
Added more midpoint cache updates
mtolmacs Nov 20, 2024
6a44401
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Nov 20, 2024
66fe0a2
Override too short fixed segment
mtolmacs Nov 21, 2024
244e6c2
Fix disconnecting elbow arrow with fixed segment
mtolmacs Nov 21, 2024
e6a6ab6
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Nov 21, 2024
1eb6bc5
Skip inverted segments
mtolmacs Nov 21, 2024
953e1ba
Fix lint
mtolmacs Nov 21, 2024
946d573
Drag distance checking
mtolmacs Nov 21, 2024
244beef
Aligned segment jump fix
mtolmacs Nov 21, 2024
83347f5
Fix multiple segment mixup
mtolmacs Nov 21, 2024
48f39a5
Another reimplementation
mtolmacs Nov 23, 2024
dbc56e2
Fix freestanding
mtolmacs Nov 23, 2024
c247bae
Broken but logic-wise laid out static fixed segment
mtolmacs Nov 27, 2024
948786f
Start point is detected as segment move
mtolmacs Nov 28, 2024
4c98a3b
Move only update one or two points
mtolmacs Nov 28, 2024
177d215
Fixed start/end point move
mtolmacs Nov 28, 2024
ce7736d
Relative point calc fix
mtolmacs Nov 28, 2024
10d1b42
Midpoint fixed in inverse move
mtolmacs Nov 29, 2024
7cc2b88
Disable midpoint cache update for elbow arrows
mtolmacs Nov 29, 2024
cb7a28b
Use midpoint cache
mtolmacs Dec 2, 2024
4efb41c
Fixed segment delete
mtolmacs Dec 2, 2024
6cbeaa2
Fix dragged element not updating elbow arrow mid points
mtolmacs Dec 3, 2024
2dd2710
Testing dynamic bbox change for smooth fixed segment sizing
mtolmacs Dec 3, 2024
8073c42
More expansive bounding box while segment is fixed
mtolmacs Dec 4, 2024
7234603
Fixed segment now shows marker midpoint
mtolmacs Dec 4, 2024
2ee045b
Remove debug
mtolmacs Dec 4, 2024
ec4ed69
Small reformats
mtolmacs Dec 4, 2024
72b3434
Small cleanups and fixes
mtolmacs Dec 5, 2024
3327f93
Fix jumping arrow on binding
mtolmacs Dec 5, 2024
c3e7ede
Add new arrow point debug draw fn
mtolmacs Dec 5, 2024
af229f0
Fix very close to start or end fixed segment positioning
mtolmacs Dec 5, 2024
6410f9e
fix: update old blog links & add canonical url (#8846)
dwelle Nov 26, 2024
55b775d
feat: in canvas links between shapes (#8812)
ryan-di Nov 26, 2024
fab1211
fix: element link selector dialog z-index & positioning (#8853)
dwelle Nov 26, 2024
bed4d25
fix: normalize svg using only absolute sizing (#8854)
ryan-di Nov 27, 2024
a290b3a
Fixed no rerender after fixed segment delete
mtolmacs Dec 8, 2024
b33589e
Fix too fast dragging drops fixed segment handle
mtolmacs Dec 8, 2024
10f52f5
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Dec 9, 2024
75ff447
Direction ignored while arrow is segmented
mtolmacs Dec 9, 2024
6306de1
Test fixes [skip ci]
mtolmacs Dec 9, 2024
699e88e
Fix incorrect heading in fixed segment parallel start/end
mtolmacs Dec 9, 2024
e8b9a14
Remove debug & fix lint error
mtolmacs Dec 9, 2024
dd68590
Parallel 1-3 segments are now properly fix the adjacent fixed segment…
mtolmacs Dec 10, 2024
a8ec32c
Fix segment endpoint alignment
mtolmacs Dec 10, 2024
c891b5a
Fix sometimes not rendering fixed control midpoint
mtolmacs Dec 11, 2024
1768891
Expose debug commands via window
mtolmacs Dec 11, 2024
e992688
Half-done multi-segment move fix [skip ci]
mtolmacs Dec 11, 2024
2e01f58
Multi-fixed segments work in common cases
mtolmacs Dec 12, 2024
3e6ac4d
Reverting previous adaptation
mtolmacs Dec 12, 2024
4b7c2f8
Simplified iteration
mtolmacs Dec 13, 2024
c6e1cb7
One way to fix segments in a stable form (with bad edge cases)
mtolmacs Dec 14, 2024
a48db08
Truly fixed segments
mtolmacs Dec 14, 2024
3bdc8f3
Circumventing existing midpoint handling
mtolmacs Dec 15, 2024
298213d
Circumventing existing midpoint handling
mtolmacs Dec 15, 2024
f2bc66d
Snapshot updates
mtolmacs Dec 15, 2024
bdd7daf
Simplified approach
mtolmacs Dec 16, 2024
3c83956
Fix test
mtolmacs Dec 16, 2024
e3bfe4a
Additional test fix
mtolmacs Dec 16, 2024
2ec50c5
Fix Z configuration fixed segments
mtolmacs Dec 16, 2024
c46debd
Fix Z configuration fixed segments
mtolmacs Dec 16, 2024
7f568e7
Lint and test fix
mtolmacs Dec 16, 2024
45c66a3
Fix for multiple steps ahead
mtolmacs Dec 16, 2024
24a6bfa
Forward options for fixed segment data generator
mtolmacs Dec 17, 2024
0acc8af
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Dec 17, 2024
6aa8258
Elbow arrows don't need size updates separately
mtolmacs Dec 17, 2024
3f47312
Smarter start point [skip ci]
mtolmacs Dec 17, 2024
6c34291
Fixing bugs related to direction [skip ci]
mtolmacs Dec 18, 2024
6103dcf
Attempt at point simplification [skip ci]
mtolmacs Dec 18, 2024
4414690
More stable variant [skip ci]
mtolmacs Dec 19, 2024
0363255
Add direct translation [skip ci]
mtolmacs Dec 20, 2024
b7e575c
Segment fixing [skip ci]
mtolmacs Dec 20, 2024
02d18e9
Refactor [skip ci]
mtolmacs Dec 20, 2024
5431f90
Moving points [skip ci]
mtolmacs Dec 20, 2024
d4b6970
Remove extra points on both ends for fixed segments [skip ci]
mtolmacs Dec 21, 2024
82a62a8
Reverse path fix [skip ci]
mtolmacs Dec 21, 2024
0e87ade
Simplify & refactor [skip ci]
mtolmacs Dec 21, 2024
0397788
Add special start and end handling [skip ci]
mtolmacs Dec 22, 2024
4d256bf
Segment reset/delete fixed [skip ci]
mtolmacs Dec 22, 2024
e0e611a
Add cursor change for midpoint hovers
mtolmacs Dec 22, 2024
e76816a
Fix test snapshots
mtolmacs Dec 22, 2024
8c36d6a
Refactoring
mtolmacs Dec 22, 2024
fb1ce18
Refactor [skip ci]
mtolmacs Dec 24, 2024
74afb02
Padding on first and last segment when element is connected
mtolmacs Dec 24, 2024
0d374f1
Removal attempts to restore an optimal route
mtolmacs Dec 25, 2024
a87ff50
fix: regression on dragging a selected frame by its name (#8924)
mtolmacs Dec 25, 2024
6f0a0a0
fix: robust `state.editingFrame` teardown (#8941)
mtolmacs Dec 25, 2024
b9a2cc4
fix: make arrow binding area adapt to zoom levels (#8927)
mtolmacs Dec 25, 2024
549fbc3
fix: normalizeSVG width and height from viewbox when size includes de…
mtolmacs Dec 25, 2024
86c31b2
refactor: separate resizing logic from pointer (#8155)
mtolmacs Dec 26, 2024
2044476
Remove debug
mtolmacs Dec 26, 2024
cecece7
Merge branch 'master' into feat/elbow-arrow-movable-segments
mtolmacs Dec 26, 2024
e7ef0b4
fix: make arrow binding area adapt to zoom levels (#8927)
ryan-di Dec 22, 2024
86f8a89
refactor: separate resizing logic from pointer (#8155)
ryan-di Dec 23, 2024
ce7cf8b
Bring over elbow move
mtolmacs Dec 26, 2024
efc93c5
Remove unneeded types [skip ci]
mtolmacs Dec 26, 2024
49987ff
Remove dead code
mtolmacs Dec 26, 2024
9b0fdbf
Remove more dead code [skip ci]
mtolmacs Dec 26, 2024
d8ce2a9
Fix resizing for elbow arrow fixed points
mtolmacs Dec 26, 2024
b9a1819
Fix duplication
mtolmacs Dec 26, 2024
f682993
Restore drifting flip mitigation
mtolmacs Dec 26, 2024
2ad925c
Fix start and end drift
mtolmacs Dec 26, 2024
604e46d
Segment delete renormalization
mtolmacs Dec 27, 2024
664a64c
Restore routes from mid point
mtolmacs Dec 27, 2024
44c7a32
Normalize elbow arrow after segment release
mtolmacs Dec 27, 2024
1e8ef4c
Fix 3-point U config
mtolmacs Dec 27, 2024
04856bb
Fix segment move z-order issue
mtolmacs Dec 27, 2024
832784e
Fix remove segment simplification
mtolmacs Dec 27, 2024
f4aed2b
Fix padding for first and last segment when moved
mtolmacs Dec 27, 2024
8ef2849
Do not remove non-rerouted fixed segments
mtolmacs Dec 27, 2024
0155f52
Fix jumping start and end segment unification
mtolmacs Dec 27, 2024
0b141df
Lint fix
mtolmacs Dec 27, 2024
42905f3
Avoid too short start and end bound segment moving
mtolmacs Dec 27, 2024
c8905c3
Fix non-right-angle fixed segment
mtolmacs Dec 30, 2024
d88f245
Remove more unneeded points during reconciliation
mtolmacs Dec 30, 2024
3bad083
Renormalize elbow arrow when indirectly changed
mtolmacs Dec 30, 2024
fe5d8fd
Renormalize on segment delete
mtolmacs Dec 30, 2024
b26c7be
Fixes for point renormalization and deduplication
mtolmacs Dec 30, 2024
a29d601
Fix test and add logging to simplification
mtolmacs Dec 31, 2024
311b561
Fix broken arrow on segment move
mtolmacs Jan 3, 2025
1c7b4c5
Make non-fixed arrow segment unification zoom-dependent too
mtolmacs Jan 3, 2025
177b30b
If no fixed segments after reunification, re-route the arrow with sim…
mtolmacs Jan 3, 2025
df40e38
Fix flipping incorrect routing
mtolmacs Jan 3, 2025
1f7e581
Restore fixed-size unification distance
mtolmacs Jan 4, 2025
744c713
Fix API and element restore for elbow arrows
mtolmacs Jan 4, 2025
cb56a27
Master manual merge
mtolmacs Jan 6, 2025
aac1350
Fix free-standing elbow arrow
mtolmacs Jan 6, 2025
83985b9
Trigger rebuild
mtolmacs Jan 7, 2025
dc1cf60
fix: package build fails on worker chunks (#8990)
Mrazator Jan 7, 2025
dde1edb
Fix arrow point simplification for free-standing arrows
mtolmacs Jan 7, 2025
e72ae3f
Elbow handle size zoom-dependent and more lenient
mtolmacs Jan 7, 2025
936b0c3
Fix for incorrect short segment checking and ghost midpoints
mtolmacs Jan 7, 2025
242bff1
Fix regression where connected elbow arrow can be dragged away from b…
mtolmacs Jan 7, 2025
ffb4942
Fix segment moving
mtolmacs Jan 8, 2025
eaf9019
Fix highlight on hover of midpoints
mtolmacs Jan 9, 2025
5182070
Constant size hover hitbox for linear element points
mtolmacs Jan 9, 2025
ce2b390
Hover size fix #2
mtolmacs Jan 9, 2025
9e4cec9
Prioritize segment midpoint highlighting over endpoint highlighting
mtolmacs Jan 9, 2025
3ccfcd1
Fix endpoint hover effect
mtolmacs Jan 9, 2025
0a4c212
fix: change cursor by tool change immediately (#8212)
yongjoon-km Jan 9, 2025
fdb8e04
Fix hover effect triggers
mtolmacs Jan 9, 2025
22b2e91
feat: add action to wrap selected items in a frame (#9005)
ryan-di Jan 13, 2025
cae41e7
fix: Test failure due to FP accuracy
mtolmacs Jan 13, 2025
8ff7fbe
Remove deep memo
mtolmacs Jan 14, 2025
acda68e
Comment on the special attributes for elbow arrows
mtolmacs Jan 14, 2025
031b0a8
remove elbow-only attrs from ExcalidrawArrowElement
dwelle Jan 14, 2025
0ef22d6
fix: arrow binding behaving unexpectedly on pointerup (#9010)
dwelle Jan 14, 2025
e11c2fa
feat: do not delete frame children on frame delete (#9011)
dwelle Jan 14, 2025
4ce0d52
Merge branch 'master' into feat/elbow-segment-move
mtolmacs Jan 15, 2025
b452a28
Fix merge error
mtolmacs Jan 15, 2025
f652c01
Use selectedLinearElement
mtolmacs Jan 15, 2025
d4e143a
Fix hover highlight when segment is released
mtolmacs Jan 15, 2025
6183574
Fix point release double click
mtolmacs Jan 15, 2025
7d1a85f
Add more bias to test
mtolmacs Jan 15, 2025
2496a43
Debug info on grabbing midpoints
mtolmacs Jan 15, 2025
0257dd5
Debug
mtolmacs Jan 16, 2025
ae2d383
Remove debug
mtolmacs Jan 16, 2025
b760800
Lint: Remove non-needed imports
mtolmacs Jan 16, 2025
ed671b0
Potentially fix misclick issue
mtolmacs Jan 16, 2025
f6c5ed2
Fix elbow arrow test
mtolmacs Jan 16, 2025
4349d1c
Attempt at better segment restore
mtolmacs Jan 16, 2025
685f9b5
Remove non-needed debug code
mtolmacs Jan 16, 2025
23f5636
Be more discriminating about elbow arrow mutation
mtolmacs Jan 16, 2025
b94a19e
Remove unneeded types
mtolmacs Jan 16, 2025
cee5d7b
Snapshot updates, lint updates
mtolmacs Jan 16, 2025
2f7bc1d
Lint fix
mtolmacs Jan 16, 2025
c04bc97
Fix close move for fixed segments
mtolmacs Jan 16, 2025
9741bfc
Added flushSync to deleteFixedSegment
mtolmacs Jan 16, 2025
f3ccbfa
Revert flushSync
mtolmacs Jan 16, 2025
638d6ca
Fix incorrect invariant
mtolmacs Jan 17, 2025
027de5d
Add documentation
mtolmacs Jan 17, 2025
9679507
Remove changedElements from mutateElement
mtolmacs Jan 17, 2025
f50a464
Wrap invariants in DEV check
mtolmacs Jan 17, 2025
d7f4069
invariant checks should run unless PROD
mtolmacs Jan 17, 2025
09dda9d
types
dwelle Jan 17, 2025
b7b144b
Rename elbowarrow.ts
mtolmacs Jan 17, 2025
b01ae63
Merge branch 'master' into feat/elbow-segment-move
mtolmacs Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions packages/excalidraw/actions/actionDeleteSelected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ import {
import { updateActiveTool } from "../utils";
import { TrashIcon } from "../components/icons";
import { StoreAction } from "../store";
import { mutateElbowArrow } from "../element/routing";

const deleteSelectedElements = (
elements: readonly ExcalidrawElement[],
appState: AppState,
app: AppClassProperties,
) => {
const elementsMap = app.scene.getNonDeletedElementsMap();
const framesToBeDeleted = new Set(
getSelectedElements(
elements.filter((el) => isFrameLikeElement(el)),
Expand All @@ -51,7 +49,7 @@ const deleteSelectedElements = (
endBinding:
el.id === bound.endBinding?.elementId ? null : bound.endBinding,
});
mutateElbowArrow(bound, elementsMap, bound.points);
mutateElement(bound, { points: bound.points });
}
});
}
Expand Down Expand Up @@ -208,12 +206,7 @@ export const actionDeleteSelected = register({
: endBindingElement,
};

LinearElementEditor.deletePoints(
element,
selectedPointsIndices,
elementsMap,
appState.zoom,
);
LinearElementEditor.deletePoints(element, selectedPointsIndices);

return {
elements,
Expand Down
19 changes: 10 additions & 9 deletions packages/excalidraw/actions/actionFlip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ describe("flipping re-centers selection", () => {
},
startArrowhead: null,
endArrowhead: "arrow",
fixedSegments: null,
points: [
pointFrom(0, 0),
pointFrom(0, -35),
pointFrom(-90.9, -35),
pointFrom(-90.9, 204.9),
pointFrom(65.1, 204.9),
pointFrom(-90, -35),
pointFrom(-90, 204),
pointFrom(66, 204),
],
elbowed: true,
}),
Expand All @@ -70,13 +71,13 @@ describe("flipping re-centers selection", () => {
API.executeAction(actionFlipHorizontal);
API.executeAction(actionFlipHorizontal);

const rec1 = h.elements.find((el) => el.id === "rec1");
expect(rec1?.x).toBeCloseTo(100);
expect(rec1?.y).toBeCloseTo(100);
const rec1 = h.elements.find((el) => el.id === "rec1")!;
expect(rec1.x).toBeCloseTo(100, 0);
expect(rec1.y).toBeCloseTo(100, 0);

const rec2 = h.elements.find((el) => el.id === "rec2");
expect(rec2?.x).toBeCloseTo(220);
expect(rec2?.y).toBeCloseTo(250);
const rec2 = h.elements.find((el) => el.id === "rec2")!;
expect(rec2.x).toBeCloseTo(220, 0);
expect(rec2.y).toBeCloseTo(250, 0);
});
});

Expand Down
40 changes: 23 additions & 17 deletions packages/excalidraw/actions/actionFlip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
isElbowArrow,
isLinearElement,
} from "../element/typeChecks";
import { mutateElbowArrow } from "../element/routing";
import { mutateElement, newElementWith } from "../element/mutateElement";
import { deepCopyElement } from "../element/newElement";
import { getCommonBoundingBox } from "../element/bounds";

export const actionFlipHorizontal = register({
Expand Down Expand Up @@ -134,12 +134,24 @@ const flipElements = (

const { midX, midY } = getCommonBoundingBox(selectedElements);

resizeMultipleElements(selectedElements, elementsMap, "nw", app.scene, {
flipByX: flipDirection === "horizontal",
flipByY: flipDirection === "vertical",
shouldResizeFromCenter: true,
shouldMaintainAspectRatio: true,
});
resizeMultipleElements(
selectedElements,
elementsMap,
"nw",
app.scene,
new Map(
Array.from(elementsMap.values()).map((element) => [
element.id,
deepCopyElement(element),
]),
),
{
flipByX: flipDirection === "horizontal",
flipByY: flipDirection === "vertical",
shouldResizeFromCenter: true,
shouldMaintainAspectRatio: true,
},
);

bindOrUnbindLinearElements(
selectedElements.filter(isLinearElement),
Expand Down Expand Up @@ -181,16 +193,10 @@ const flipElements = (
}),
);
elbowArrows.forEach((element) =>
mutateElbowArrow(
element,
elementsMap,
element.points,
undefined,
undefined,
{
informMutation: false,
},
),
mutateElement(element, {
x: element.x + diffX,
y: element.y + diffY,
}),
);
// ---------------------------------------------------------------------------

Expand Down
Loading
Loading