aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/InkControls.tsx14
-rw-r--r--src/client/views/InkHandles.tsx1
-rw-r--r--src/client/views/InkStrokeProperties.ts18
3 files changed, 18 insertions, 15 deletions
diff --git a/src/client/views/InkControls.tsx b/src/client/views/InkControls.tsx
index 090af10cc..6213a4075 100644
--- a/src/client/views/InkControls.tsx
+++ b/src/client/views/InkControls.tsx
@@ -37,20 +37,18 @@ export class InkControls extends React.Component<InkControlProps> {
const order = controlIndex % 4;
const handleIndexA = order === 2 ? controlIndex - 1 : controlIndex - 2;
const handleIndexB = order === 2 ? controlIndex + 2 : controlIndex + 1;
- const brokenIndices = Cast(this.props.inkDoc, listSpec("number"));
+ const brokenIndices = Cast(this.props.inkDoc.brokenInkIndices, listSpec("number"));
setupMoveUpEvents(this, e,
(e: PointerEvent, down: number[], delta: number[]) => {
InkStrokeProperties.Instance?.moveControl(-delta[0] * screenScale, -delta[1] * screenScale, controlIndex);
return false;
},
() => controlUndo?.end(),
- brokenIndices ?
- action((e: PointerEvent, doubleTap: boolean | undefined) => {
- if (doubleTap && brokenIndices.includes(controlIndex)) {
- InkStrokeProperties.Instance?.snapHandleTangent(controlIndex, handleIndexA, handleIndexB);
- }
- })
- : emptyFunction);
+ action((e: PointerEvent, doubleTap: boolean | undefined) => {
+ if (doubleTap && brokenIndices && brokenIndices.includes(controlIndex)) {
+ InkStrokeProperties.Instance?.snapHandleTangent(controlIndex, handleIndexA, handleIndexB);
+ }
+ }));
}
}
diff --git a/src/client/views/InkHandles.tsx b/src/client/views/InkHandles.tsx
index 6e890e184..f1eb4b9db 100644
--- a/src/client/views/InkHandles.tsx
+++ b/src/client/views/InkHandles.tsx
@@ -51,6 +51,7 @@ export class InkHandles extends React.Component<InkHandlesProps> {
onBreakTangent = (e: KeyboardEvent, controlIndex: number) => {
const doc: Doc = this.props.inkDoc;
if (["Alt"].includes(e.key)) {
+ e.stopPropagation();
if (doc) {
const brokenIndices = Cast(doc.brokenInkIndices, listSpec("number")) || new List;
if (brokenIndices && !brokenIndices.includes(controlIndex)) {
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index de8cf80bd..76ca5b5ec 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -257,6 +257,11 @@ export class InkStrokeProperties {
return newPoints;
})
+ /**
+ * Snaps a control point with broken tangency back to synced rotation.
+ * @param handleIndexA The handle point that retains its current position.
+ * @param handleIndexB The handle point that is rotated to be 180 degrees from its opposite.
+ */
snapHandleTangent = (controlIndex: number, handleIndexA: number, handleIndexB: number) => {
this.applyFunction((doc: Doc, ink: InkData) => {
const brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
@@ -278,13 +283,12 @@ export class InkStrokeProperties {
*/
@action
rotatePoint = (target: PointData, origin: PointData, angle: number) => {
- target.X -= origin.X;
- target.Y -= origin.Y;
- const newX = Math.cos(angle) * target.X - Math.sin(angle) * target.Y;
- const newY = Math.sin(angle) * target.X + Math.cos(angle) * target.Y;
- target.X = newX + origin.X;
- target.Y = newY + origin.Y;
- return target;
+ let rotatedTarget = { X: target.X - origin.X, Y: target.Y - origin.Y };
+ const newX = Math.cos(angle) * rotatedTarget.X - Math.sin(angle) * rotatedTarget.Y;
+ const newY = Math.sin(angle) * rotatedTarget.X + Math.cos(angle) * rotatedTarget.Y;
+ rotatedTarget.X = newX + origin.X;
+ rotatedTarget.Y = newY + origin.Y;
+ return rotatedTarget;
}
/**