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( const { before, after } = TLDR.mutateShapes(
app.state, app.state,
ids.filter((id) => deltaMap[id] !== undefined), ids.filter((id) => deltaMap[id] !== undefined),
(shape) => ({ point: deltaMap[shape.id].next }), (shape) => ({ point: deltaMap[shape.id]?.next }),
currentPageId currentPageId
) )

View file

@ -89,7 +89,7 @@ describe('Flip command', () => {
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 0]) expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 100]) 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.group(
[app.getShape<RectangleShape>('rect1').id, app.getShape<RectangleShape>('rect2').id], [app.getShape<RectangleShape>('rect1').id, app.getShape<RectangleShape>('rect2').id],
'groupId' 'groupId'
@ -100,11 +100,11 @@ describe('Flip command', () => {
app.flipHorizontal() app.flipHorizontal()
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([0, 0]) expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 0])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([100, 100]) expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 100])
app.flipVertical() app.flipVertical()
expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([0, 0]) expect(app.getShape<RectangleShape>('rect1').point).toStrictEqual([100, 100])
expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([100, 100]) expect(app.getShape<RectangleShape>('rect2').point).toStrictEqual([0, 0])
}) })
}) })