diff options
author | vkalev <vjk1883@gmail.com> | 2021-10-21 16:44:12 -0400 |
---|---|---|
committer | vkalev <vjk1883@gmail.com> | 2021-10-21 16:44:12 -0400 |
commit | bf896f7f7c287c9a78cca91d7ceab88f66613b61 (patch) | |
tree | 3337e3599754f57bcb4a554c8fc89eff30f30650 | |
parent | 687b51a3de67eca11fcc1bd11964d93acc1f56d9 (diff) |
changing rotation
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 24 | ||||
-rw-r--r-- | src/client/views/InkStrokeProperties.ts | 6 |
2 files changed, 13 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; }, () => { diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index ee30caa3d..ba85b851c 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -259,11 +259,17 @@ export class InkStrokeProperties { if (near / (this.selectedInk?.lastElement().props.ScreenToLocalTransform().Scale || 1) < 10) { return this.moveControlPtHandle((nearestPt.X - ink[controlIndex].X) * ptsXscale, (nearestPt.Y - ink[controlIndex].Y) * ptsYscale, controlIndex); + } else { + return } } return false; } + // snapControlBetweenCurves = (ink, controlIndex) => { + + // } + /** * Snaps a control point with broken tangency back to synced rotation. * @param handleIndexA The handle point that retains its current position. |