aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocumentDecorations.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/DocumentDecorations.tsx')
-rw-r--r--src/client/views/DocumentDecorations.tsx24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index b1c147747..207c7fcac 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -197,23 +197,13 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P
this._rotateUndo = UndoManager.StartBatch("rotatedown");
setupMoveUpEvents(this, e,
(e: PointerEvent, down: number[], delta: number[]) => {
- let origin;
- SelectionManager.Views().filter(dv => dv.rootDoc.type === DocumentType.INK)
- .map(doc => {
- const inkData = Cast(doc.rootDoc.data, InkField)?.inkData ?? [];
- const inkStrokeWidth = NumCast(doc.rootDoc.strokeWidth, 1);
- const inkTop = Math.min(...inkData.map(p => p.Y)) - inkStrokeWidth / 2;
- const inkBottom = Math.max(...inkData.map(p => p.Y)) + inkStrokeWidth / 2;
- const inkLeft = Math.min(...inkData.map(p => p.X)) - inkStrokeWidth / 2;
- const inkRight = Math.max(...inkData.map(p => p.X)) + inkStrokeWidth / 2;
- origin = { X: (inkLeft + inkRight) / 2, Y: (inkTop + inkBottom) / 2 };
- });
- if (origin) {
- const previousPoint = { X: e.clientX, Y: e.clientY };
- const movedPoint = { X: e.clientX - delta[0], Y: e.clientY - delta[1] };
- const angle = InkStrokeProperties.Instance?.angleChange(previousPoint, movedPoint, origin);
- if (angle) InkStrokeProperties.Instance?.rotateInk(-angle);
- }
+ const docView = SelectionManager.Views()[0];
+ const { left, top, right, bottom } = docView.getBounds() || { left: 0, top: 0, right: 0, bottom: 0 };
+ const centerPoint = { X: (left + right) / 2, Y: (top + bottom) / 2 };
+ const previousPoint = { X: e.clientX, Y: e.clientY };
+ const movedPoint = { X: e.clientX - delta[0], Y: e.clientY - delta[1] };
+ const angle = InkStrokeProperties.Instance?.angleChange(previousPoint, movedPoint, centerPoint);
+ if (angle) InkStrokeProperties.Instance?.rotateInk(-angle);
return false;
},
() => {