From fabaad0251cf4f64c1af7a37a5f3d6622011c058 Mon Sep 17 00:00:00 2001 From: vkalev Date: Thu, 22 Jul 2021 11:30:18 -0400 Subject: adding broken indices to layoutDoc working --- src/client/views/InkStrokeProperties.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/client/views/InkStrokeProperties.ts') diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts index 4c225210e..f218b4fbf 100644 --- a/src/client/views/InkStrokeProperties.ts +++ b/src/client/views/InkStrokeProperties.ts @@ -15,7 +15,6 @@ export class InkStrokeProperties { @observable _lock = false; @observable _controlButton = false; @observable _currentPoint = -1; - // @observable _brokenIndices: List = new List(); constructor() { InkStrokeProperties.Instance = this; @@ -112,11 +111,9 @@ export class InkStrokeProperties { } } - let brokenIndices = Cast(doc.brokenInkIndices, listSpec("number")); - // Updating the indices of the control points whose handle tangency has been broken. - if(brokenIndices){ + if (brokenIndices) { brokenIndices = new List(brokenIndices.map((control) => { if (control >= newIndex) { return control + 4; @@ -283,7 +280,7 @@ export class InkStrokeProperties { } /** - * Finds the angle between two inputted vectors. + * Finds the angle (in radians) between two inputted vectors. * * α = arccos(a·b / |a|·|b|), where a and b are both vectors. */ @@ -323,9 +320,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")); + const 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 (brokenIndices && !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; -- cgit v1.2.3-70-g09d2