|
|
@@ -45,7 +45,14 @@ export default class RotateSession extends BaseSession {
|
|
45
|
45
|
const shape = page.shapes[id]
|
|
46
|
46
|
|
|
47
|
47
|
getShapeUtils(shape)
|
|
48
|
|
- .rotateTo(shape, (PI2 + (rotation + rot)) % PI2)
|
|
|
48
|
+ .rotateTo(
|
|
|
49
|
+ shape,
|
|
|
50
|
+ (PI2 +
|
|
|
51
|
+ (isLocked
|
|
|
52
|
+ ? clampToRotationToSegments(rotation + rot, 24)
|
|
|
53
|
+ : rotation + rot)) %
|
|
|
54
|
+ PI2
|
|
|
55
|
+ )
|
|
49
|
56
|
.translateTo(
|
|
50
|
57
|
shape,
|
|
51
|
58
|
vec.sub(vec.rotWith(center, boundsCenter, rot % PI2), offset)
|
|
|
@@ -70,20 +77,16 @@ export default class RotateSession extends BaseSession {
|
|
70
|
77
|
export function getRotateSnapshot(data: Data) {
|
|
71
|
78
|
const shapes = getSelectedShapes(current(data))
|
|
72
|
79
|
|
|
73
|
|
- // A mapping of selected shapes and their bounds
|
|
74
|
80
|
const shapesBounds = Object.fromEntries(
|
|
75
|
81
|
shapes.map((shape) => [shape.id, getShapeBounds(shape)])
|
|
76
|
82
|
)
|
|
77
|
83
|
|
|
78
|
|
- // The common (exterior) bounds of the selected shapes
|
|
79
|
84
|
const bounds = getCommonBounds(...Object.values(shapesBounds))
|
|
80
|
85
|
|
|
81
|
|
- const boundsCenter = getBoundsCenter(bounds)
|
|
82
|
|
-
|
|
83
|
86
|
return {
|
|
84
|
|
- boundsCenter,
|
|
85
|
87
|
currentPageId: data.currentPageId,
|
|
86
|
88
|
boundsRotation: data.boundsRotation,
|
|
|
89
|
+ boundsCenter: getBoundsCenter(bounds),
|
|
87
|
90
|
shapes: shapes.map(({ id, point, rotation }) => {
|
|
88
|
91
|
const bounds = shapesBounds[id]
|
|
89
|
92
|
const offset = [bounds.width / 2, bounds.height / 2]
|