aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkStrokeProperties.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-28 17:21:24 -0400
committerbobzel <zzzman@gmail.com>2021-09-28 17:21:24 -0400
commitcad1445ea3fa81363c00908647ed2825c0f34c65 (patch)
tree61c5d88ea706fe7843ad12c9b76ab530de72ccd3 /src/client/views/InkStrokeProperties.ts
parentcaf4e2e6d14617a4105bd220e8441461c66a2e75 (diff)
fixed adding point drag location. fixed broken indices on deleting.
Diffstat (limited to 'src/client/views/InkStrokeProperties.ts')
-rw-r--r--src/client/views/InkStrokeProperties.ts16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/client/views/InkStrokeProperties.ts b/src/client/views/InkStrokeProperties.ts
index 115e75c2a..0b7fe5cd1 100644
--- a/src/client/views/InkStrokeProperties.ts
+++ b/src/client/views/InkStrokeProperties.ts
@@ -10,6 +10,7 @@ import { DocumentType } from "../documents/DocumentTypes";
import { CurrentUserUtils } from "../util/CurrentUserUtils";
import { SelectionManager } from "../util/SelectionManager";
import { undoBatch } from "../util/UndoManager";
+import { last } from "lodash";
export class InkStrokeProperties {
static Instance: InkStrokeProperties | undefined;
@@ -83,18 +84,8 @@ export class InkStrokeProperties {
const newsegs = new Bezier(array).split(t);
controls.splice(i, 4, ...[...newsegs.left.points.map(p => ({ X: p.x, Y: p.y })), ...newsegs.right.points.map(p => ({ X: p.x, Y: p.y }))]);
- let brokenIndices = Cast(doc.brokenInkIndices, listSpec("number"));
// Updating the indices of the control points whose handle tangency has been broken.
- if (brokenIndices) {
- brokenIndices = new List(brokenIndices.map((control) => {
- if (control > i) {
- return control + 4;
- } else {
- return control;
- }
- }));
- }
- doc.brokenInkIndices = brokenIndices;
+ doc.brokenInkIndices = new List(Cast(doc.brokenInkIndices, listSpec("number"), []).map(control => control > i ? control + 4 : control));
this._currentPoint = -1;
return controls;
@@ -160,11 +151,14 @@ export class InkStrokeProperties {
deletePoints = () => this.applyFunction((doc: Doc, ink: InkData) => {
const newPoints: { X: number, Y: number }[] = [];
const toRemove = Math.floor(((this._currentPoint + 2) / 4));
+ const last = this._currentPoint === ink.length - 1;
for (let i = 0; i < ink.length; i++) {
if (Math.floor((i + 2) / 4) !== toRemove && (toRemove !== 0 || i > 3)) {
newPoints.push({ X: ink[i].X, Y: ink[i].Y });
}
}
+ doc.brokenInkIndices = new List(Cast(doc.brokenInkIndices, listSpec("number"), []).map(control => control >= toRemove * 4 ? control - 4 : control));
+ if (last) newPoints.splice(newPoints.length - 3, 2);
this._currentPoint = -1;
if (newPoints.length < 4) return undefined;
if (newPoints.length === 4) {