aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkStrokeProperties.ts
diff options
context:
space:
mode:
authorgeireann <60007097+geireann@users.noreply.github.com>2021-07-17 13:51:25 -0400
committergeireann <60007097+geireann@users.noreply.github.com>2021-07-17 13:51:25 -0400
commite3b1401b854e5f968385dcc469c02fae86308bea (patch)
treed176eb8e0c9de275d70bbe707ed31bc53bd9306e /src/client/views/InkStrokeProperties.ts
parent48620bbe25f92eb179d53846aae5f0164ca6f1c2 (diff)
added broken indices to layoutDoc
:broken_heart:
Diffstat (limited to 'src/client/views/InkStrokeProperties.ts')
-rw-r--r--src/client/views/InkStrokeProperties.ts31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index a3f7562e0..4c225210e 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -1,7 +1,9 @@
import { action, computed, observable } from "mobx";
-import { Doc, Field, Opt } from "../../fields/Doc";
+import { Doc, DocListCast, Field, Opt } from "../../fields/Doc";
import { Document } from "../../fields/documentSchemas";
import { InkField, InkData, PointData, ControlPoint } from "../../fields/InkField";
+import { List } from "../../fields/List";
+import { listSpec } from "../../fields/Schema";
import { Cast, NumCast } from "../../fields/Types";
import { DocumentType } from "../documents/DocumentTypes";
import { SelectionManager } from "../util/SelectionManager";
@@ -13,7 +15,7 @@ export class InkStrokeProperties {
@observable _lock = false;
@observable _controlButton = false;
@observable _currentPoint = -1;
- @observable _brokenIndices: number[] = [];
+ // @observable _brokenIndices: List<number> = new List<number>();
constructor() {
InkStrokeProperties.Instance = this;
@@ -110,14 +112,20 @@ export class InkStrokeProperties {
}
}
+
+ let brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
+
// Updating the indices of the control points whose handle tangency has been broken.
- this._brokenIndices = this._brokenIndices.map((control) => {
- if (control >= newIndex) {
- return control + 4;
- } else {
- return control;
- }
- });
+ if(brokenIndices){
+ brokenIndices = new List(brokenIndices.map((control) => {
+ if (control >= newIndex) {
+ return control + 4;
+ } else {
+ return control;
+ }
+ }));
+ }
+ doc.brokenInkIndices = brokenIndices;
this._currentPoint = -1;
return newPoints;
});
@@ -250,7 +258,7 @@ export class InkStrokeProperties {
snapHandleTangent = (controlIndex: number, handleIndexA: number, handleIndexB: number) => {
this.applyFunction((doc: Doc, ink: InkData) => {
- this._brokenIndices.splice(this._brokenIndices.indexOf(controlIndex), 1);
+ // doc.brokenIndices.splice(this._brokenIndices.indexOf(controlIndex), 1);
const [controlPoint, handleA, handleB] = [ink[controlIndex], ink[handleIndexA], ink[handleIndexB]];
const oppositeHandleA = this.rotatePoint(handleA, controlPoint, Math.PI);
const angleDifference = this.angleChange(handleB, oppositeHandleA, controlPoint);
@@ -315,8 +323,9 @@ export class InkStrokeProperties {
const controlPoint = ink[controlIndex];
const newHandlePoint = { X: ink[handleIndex].X - deltaX / xScale, Y: ink[handleIndex].Y - deltaY / yScale };
ink[handleIndex] = newHandlePoint;
+ let brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
// Rotate opposite handle if user hasn't held 'Alt' key or not first/final control (which have only 1 handle).
- if (!this._brokenIndices.includes(controlIndex) && handleIndex !== 1 && handleIndex !== ink.length - 2) {
+ if (brokenIndices && !brokenIndices.includes(controlIndex) && handleIndex !== 1 && handleIndex !== ink.length - 2) {
const angle = this.angleChange(oldHandlePoint, newHandlePoint, controlPoint);
oppositeHandlePoint = this.rotatePoint(oppositeHandlePoint, controlPoint, angle);
ink[oppositeHandleIndex] = oppositeHandlePoint;