|
|
@@ -32,6 +32,18 @@ export default class TransformSession extends BaseSession {
|
|
32
|
32
|
super(data)
|
|
33
|
33
|
this.origin = point
|
|
34
|
34
|
this.transformType = transformType
|
|
|
35
|
+
|
|
|
36
|
+ // if (data.selectedIds.size === 1) {
|
|
|
37
|
+ // const shape =
|
|
|
38
|
+ // data.document.pages[data.currentPageId].shapes[
|
|
|
39
|
+ // Array.from(data.selectedIds.values())[0]
|
|
|
40
|
+ // ]
|
|
|
41
|
+
|
|
|
42
|
+ // if (shape.rotation > 0) {
|
|
|
43
|
+
|
|
|
44
|
+ // }
|
|
|
45
|
+ // }
|
|
|
46
|
+
|
|
35
|
47
|
this.snapshot = getTransformSnapshot(data, transformType)
|
|
36
|
48
|
|
|
37
|
49
|
const { minX, minY, maxX, maxY } = this.snapshot.initialBounds
|
|
|
@@ -43,21 +55,26 @@ export default class TransformSession extends BaseSession {
|
|
43
|
55
|
}
|
|
44
|
56
|
|
|
45
|
57
|
update(data: Data, point: number[]) {
|
|
46
|
|
- const { shapeBounds, initialBounds, currentPageId, selectedIds } =
|
|
47
|
|
- this.snapshot
|
|
48
|
|
-
|
|
49
|
|
- const { shapes } = data.document.pages[currentPageId]
|
|
50
|
|
-
|
|
51
|
|
- const delta = vec.vec(this.origin, point)
|
|
52
|
|
-
|
|
53
|
58
|
const {
|
|
54
|
59
|
corners: { a, b },
|
|
55
|
60
|
transformType,
|
|
56
|
61
|
} = this
|
|
57
|
62
|
|
|
58
|
|
- // Edge Transform
|
|
|
63
|
+ const {
|
|
|
64
|
+ boundsRotation,
|
|
|
65
|
+ shapeBounds,
|
|
|
66
|
+ initialBounds,
|
|
|
67
|
+ currentPageId,
|
|
|
68
|
+ selectedIds,
|
|
|
69
|
+ isSingle,
|
|
|
70
|
+ } = this.snapshot
|
|
|
71
|
+
|
|
|
72
|
+ const { shapes } = data.document.pages[currentPageId]
|
|
|
73
|
+
|
|
|
74
|
+ const delta = vec.vec(this.origin, point)
|
|
|
75
|
+
|
|
59
|
76
|
/*
|
|
60
|
|
- Edge transform
|
|
|
77
|
+ Transforms
|
|
61
|
78
|
|
|
62
|
79
|
Corners a and b are the original top-left and bottom-right corners of the
|
|
63
|
80
|
bounding box. Depending on what the user is dragging, change one or both
|
|
|
@@ -153,8 +170,10 @@ export default class TransformSession extends BaseSession {
|
|
153
|
170
|
initialShape,
|
|
154
|
171
|
initialShapeBounds,
|
|
155
|
172
|
initialBounds,
|
|
|
173
|
+ boundsRotation,
|
|
156
|
174
|
isFlippedX: this.isFlippedX,
|
|
157
|
175
|
isFlippedY: this.isFlippedY,
|
|
|
176
|
+ isSingle,
|
|
158
|
177
|
anchor: getTransformAnchor(
|
|
159
|
178
|
this.transformType,
|
|
160
|
179
|
this.isFlippedX,
|
|
|
@@ -165,8 +184,14 @@ export default class TransformSession extends BaseSession {
|
|
165
|
184
|
}
|
|
166
|
185
|
|
|
167
|
186
|
cancel(data: Data) {
|
|
168
|
|
- const { shapeBounds, initialBounds, currentPageId, selectedIds } =
|
|
169
|
|
- this.snapshot
|
|
|
187
|
+ const {
|
|
|
188
|
+ shapeBounds,
|
|
|
189
|
+ boundsRotation,
|
|
|
190
|
+ initialBounds,
|
|
|
191
|
+ currentPageId,
|
|
|
192
|
+ selectedIds,
|
|
|
193
|
+ isSingle,
|
|
|
194
|
+ } = this.snapshot
|
|
170
|
195
|
|
|
171
|
196
|
const { shapes } = data.document.pages[currentPageId]
|
|
172
|
197
|
|
|
|
@@ -180,8 +205,10 @@ export default class TransformSession extends BaseSession {
|
|
180
|
205
|
initialShape,
|
|
181
|
206
|
initialShapeBounds,
|
|
182
|
207
|
initialBounds,
|
|
|
208
|
+ boundsRotation,
|
|
183
|
209
|
isFlippedX: false,
|
|
184
|
210
|
isFlippedY: false,
|
|
|
211
|
+ isSingle,
|
|
185
|
212
|
anchor: getTransformAnchor(this.transformType, false, false),
|
|
186
|
213
|
})
|
|
187
|
214
|
})
|
|
|
@@ -205,6 +232,7 @@ export function getTransformSnapshot(
|
|
205
|
232
|
document: { pages },
|
|
206
|
233
|
selectedIds,
|
|
207
|
234
|
currentPageId,
|
|
|
235
|
+ boundsRotation,
|
|
208
|
236
|
} = current(data)
|
|
209
|
237
|
|
|
210
|
238
|
const pageShapes = pages[currentPageId].shapes
|
|
|
@@ -226,6 +254,8 @@ export function getTransformSnapshot(
|
|
226
|
254
|
currentPageId,
|
|
227
|
255
|
type: transformType,
|
|
228
|
256
|
initialBounds: bounds,
|
|
|
257
|
+ boundsRotation,
|
|
|
258
|
+ isSingle: selectedIds.size === 1,
|
|
229
|
259
|
selectedIds: new Set(selectedIds),
|
|
230
|
260
|
shapeBounds: Object.fromEntries(
|
|
231
|
261
|
Array.from(selectedIds.values()).map((id) => {
|