Update rectangle.tsx

This commit is contained in:
Steve Ruiz 2021-05-22 21:35:53 +01:00
parent 3310f1a94c
commit 2a28064a68

View file

@ -95,9 +95,14 @@ const rectangle = registerShapeUtils<RectangleShape>({
transform(shape, bounds, { initialShape, transformOrigin, scaleX, scaleY }) {
if (shape.rotation === 0) {
shape.point = [bounds.minX, bounds.minY]
shape.size = [bounds.width, bounds.height]
shape.point = [bounds.minX, bounds.minY]
} else {
shape.size = vec.mul(
initialShape.size,
Math.min(Math.abs(scaleX), Math.abs(scaleY))
)
shape.point = [
bounds.minX +
(bounds.width - shape.size[0]) *
@ -107,11 +112,6 @@ const rectangle = registerShapeUtils<RectangleShape>({
(scaleY < 0 ? 1 - transformOrigin[1] : transformOrigin[1]),
]
shape.size = vec.mul(
initialShape.size,
Math.min(Math.abs(scaleX), Math.abs(scaleY))
)
shape.rotation =
(scaleX < 0 && scaleY >= 0) || (scaleY < 0 && scaleX >= 0)
? -initialShape.rotation