From d335e4694e5d45f6b273410664622ea1891073c8 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 20 May 2024 15:10:54 -0400 Subject: fixing flash card carousel code organization. lint fixes. --- .../collectionFreeForm/CollectionFreeFormView.tsx | 81 +++++++++------------- 1 file changed, 34 insertions(+), 47 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 110f7816c..be96b914c 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -517,6 +517,7 @@ export class CollectionFreeFormView extends CollectionSubView { let isInside = false; if (!isNaN(eraserOutline[0].X) && !isNaN(eraserOutline[0].Y)) { - let minX = eraserOutline[0].X, - maxX = eraserOutline[0].X; - let minY = eraserOutline[0].Y, - maxY = eraserOutline[0].Y; + let [minX, minY] = [eraserOutline[0].X, eraserOutline[0].Y]; + let [maxX, maxY] = [eraserOutline[0].X, eraserOutline[0].Y]; for (let i = 1; i < eraserOutline.length; i++) { const currPoint: { X: number; Y: number } = eraserOutline[i]; minX = Math.min(currPoint.X, minX); @@ -784,7 +783,7 @@ export class CollectionFreeFormView extends CollectionSubView point.Y != eraserOutline[j].Y > point.Y && point.X < ((eraserOutline[j].X - eraserOutline[i].X) * (point.Y - eraserOutline[i].Y)) / (eraserOutline[j].Y - eraserOutline[i].Y) + eraserOutline[i].X) { + if (eraserOutline[i].Y > point.Y !== eraserOutline[j].Y > point.Y && point.X < ((eraserOutline[j].X - eraserOutline[i].X) * (point.Y - eraserOutline[i].Y)) / (eraserOutline[j].Y - eraserOutline[i].Y) + eraserOutline[i].X) { isInside = !isInside; } } @@ -845,7 +844,7 @@ export class CollectionFreeFormView extends CollectionSubView { // set distance of the eraser's bounding box based on the zoom let boundingBoxDist = ActiveEraserWidth() + 5; - this.zoomScaling() < 1 ? (boundingBoxDist = boundingBoxDist / (this.zoomScaling() * 1.5)) : (boundingBoxDist *= this.zoomScaling()); + this.zoomScaling() < 1 ? (boundingBoxDist /= this.zoomScaling() * 1.5) : (boundingBoxDist *= this.zoomScaling()); const eraserMin = { X: Math.min(lastPoint.X, currPoint.X) - boundingBoxDist, Y: Math.min(lastPoint.Y, currPoint.Y) - boundingBoxDist }; const eraserMax = { X: Math.max(lastPoint.X, currPoint.X) + boundingBoxDist, Y: Math.max(lastPoint.Y, currPoint.Y) + boundingBoxDist }; @@ -961,29 +960,25 @@ export class CollectionFreeFormView extends CollectionSubView 0) { - segments.push(currSegment); // ...so we add it to the list and reset currSegment - if (firstSegment.length === 0) { - firstSegment = currSegment; - } - currSegment = []; + // we've reached the end of the part to take out... + continueErasing = false; + if (currSegment.length > 0) { + segments.push(currSegment); // ...so we add it to the list and reset currSegment + if (firstSegment.length === 0) { + firstSegment = currSegment; } - currSegment.push(inkBezier.split(segmentTs[j] - currCurveT, 1)); + currSegment = []; } + currSegment.push(inkBezier.split(segmentTs[j] - currCurveT, 1)); } } - } else { - if (!continueErasing) { - // push the bezier piece if not in the eraser circle - currSegment.push(inkBezier); - } + } else if (!continueErasing) { + // push the bezier piece if not in the eraser circle + currSegment.push(inkBezier); } } @@ -1078,13 +1073,11 @@ export class CollectionFreeFormView extends CollectionSubView= startIndex && tVals[mid - 1] < excludeT) { + return [mid - 1, mid]; } else { - if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) { - return [mid - 1, mid]; - } else { - return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); - } + return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); } } }; -- cgit v1.2.3-70-g09d2