move grouped shape when flipping

This commit is contained in:
Judicael 2022-08-19 21:29:53 +03:00
parent ac9802570c
commit 18e47ad56b
2 changed files with 6 additions and 6 deletions

View file

@ -18,7 +18,7 @@ export function distributeShapes(
const { before, after } = TLDR.mutateShapes(
app.state,
ids.filter((id) => deltaMap[id] !== undefined),
(shape) => ({ point: deltaMap[shape.id].next }),
(shape) => ({ point: deltaMap[shape.id]?.next }),
currentPageId
)

View file

@ -89,7 +89,7 @@ describe('Flip command', () => {
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 100])
})
it('stays in the same point when the grouped shape is selected with other shape', () => {
it('move the grouped shape when flipped with other shape', () => {
app.group(
[app.getShape<RectangleShape>('rect1').id, app.getShape<RectangleShape>('rect2').id],
'groupId'
@ -100,11 +100,11 @@ describe('Flip command', () => {
app.flipHorizontal()
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([0, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([100, 100])
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 100])
app.flipVertical()
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([0, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([100, 100])
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 100])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 0])
})
})