aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkHandles.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/InkHandles.tsx')
-rw-r--r--src/client/views/InkHandles.tsx12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/client/views/InkHandles.tsx b/src/client/views/InkHandles.tsx
index ffb6986f1..28b6dd820 100644
--- a/src/client/views/InkHandles.tsx
+++ b/src/client/views/InkHandles.tsx
@@ -8,9 +8,10 @@ import { InkData, HandlePoint, HandleLine } from "../../fields/InkField";
import { Transform } from "../util/Transform";
import { Doc } from "../../fields/Doc";
import { listSpec } from "../../fields/Schema";
+import { List } from "../../fields/List";
import { Cast } from "../../fields/Types";
-export interface InkControlProps {
+export interface InkHandlesProps {
inkDoc: Doc;
data: InkData;
format: number[];
@@ -18,7 +19,7 @@ export interface InkControlProps {
}
@observer
-export class InkHandles extends React.Component<InkControlProps> {
+export class InkHandles extends React.Component<InkHandlesProps> {
/**
* Handles the movement of a selected handle point when the user clicks and drags.
* @param handleNum The index of the currently selected handle point.
@@ -50,11 +51,10 @@ export class InkHandles extends React.Component<InkControlProps> {
const doc: Doc = this.props.inkDoc;
if (["Alt"].includes(e.key)) {
if (doc) {
- let brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
- if (brokenIndices && brokenIndices.includes(controlIndex)) {
+ const brokenIndices = Cast(doc.brokenInkIndices, listSpec("number")) || new List;
+ if (brokenIndices && !brokenIndices.includes(controlIndex)) {
brokenIndices.push(controlIndex);
}
-
doc.brokenInkIndices = brokenIndices;
}
}
@@ -73,7 +73,7 @@ export class InkHandles extends React.Component<InkControlProps> {
handlePoints.push({ X: data[i + 1].X, Y: data[i + 1].Y, I: i + 1, dot1: i, dot2: i === 0 ? i : i - 1 });
handlePoints.push({ X: data[i + 2].X, Y: data[i + 2].Y, I: i + 2, dot1: i + 3, dot2: i === data.length ? i + 3 : i + 4 });
}
- // adding first and last (single) handle lines
+ // Adding first and last (single) handle lines.
handleLines.push({ X1: data[0].X, Y1: data[0].Y, X2: data[0].X, Y2: data[0].Y, X3: data[1].X, Y3: data[1].Y, dot1: 0, dot2: 0 });
handleLines.push({ X1: data[data.length - 2].X, Y1: data[data.length - 2].Y, X2: data[data.length - 1].X, Y2: data[data.length - 1].Y, X3: data[data.length - 1].X, Y3: data[data.length - 1].Y, dot1: data.length - 1, dot2: data.length - 1 });
for (let i = 2; i < data.length - 4; i += 4) {