From a7f5bd1c2438f95252f5515d7226b491dfb5183b Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 24 May 2024 11:27:56 -0400 Subject: lint fixes --- .../collectionFreeForm/CollectionFreeFormView.tsx | 66 +++++++++++----------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index be96b914c..b6e1fca77 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -894,7 +894,7 @@ export class CollectionFreeFormView extends CollectionSubView Math.abs(val - (t + Math.floor(i / 4))) <= tValOffset); + const inList = inkList.some(ival => Math.abs(ival - (t + Math.floor(i / 4))) <= tValOffset); if (!inList) { inkList.push(t + Math.floor(i / 4)); } @@ -1007,7 +1007,7 @@ export class CollectionFreeFormView extends CollectionSubView { if (tVals[startIndex] >= excludeT) { return [-1, startIndex]; - } else if (tVals[endIndex] < excludeT) { + } + if (tVals[endIndex] < excludeT) { return [endIndex, -1]; - } else { - const mid = Math.floor((startIndex + endIndex) / 2); - if (excludeT >= tVals[mid]) { - if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) { - return [mid, mid + 1]; - } else { - return this.getClosestTs(tVals, excludeT, mid + 1, endIndex); - } - } else if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) { - return [mid - 1, mid]; - } else { - return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); + } + const mid = Math.floor((startIndex + endIndex) / 2); + if (excludeT >= tVals[mid]) { + if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) { + return [mid, mid + 1]; } + return this.getClosestTs(tVals, excludeT, mid + 1, endIndex); + } + if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) { + return [mid - 1, mid]; } + return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); }; // for some reason bezier.js doesn't handle the case of intersecting a linear curve, so we wrap the intersection @@ -1212,10 +1210,10 @@ export class CollectionFreeFormView extends CollectionSubView { + this.bintersects(curve, otherCurve).forEach((val: string | number, ival: number) => { // Converting the Bezier.js Split type to a t-value number. const t = +val.toString().split('/')[0]; - if (i % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack! don't know why but intersection points are doubled from bezier.js (but not identical). + if (ival % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack! don't know why but intersection points are doubled from bezier.js (but not identical). }); if (bpt.d !== undefined && bpt.d < 1 && bpt.t !== undefined && !tVals.includes(bpt.t)) { tVals.push(bpt.t); @@ -1775,8 +1773,8 @@ export class CollectionFreeFormView extends CollectionSubView { if (!code.includes('dashDiv')) { const script = CompileScript(code, { params: { docView: 'any' }, typecheck: false, editable: true }); - // eslint-disable-next-line no-eval if (script.compiled) script.run({ this: this.DocumentView?.() }); + // eslint-disable-next-line no-eval } else code && !first && eval?.(code); }, { fireImmediately: true } -- cgit v1.2.3-70-g09d2