fix index

This commit is contained in:
Aakansha Doshi 2022-09-01 18:03:49 +05:30
parent 330b3a0530
commit 0b0846bd8e

View file

@ -791,19 +791,20 @@ export class LinearElementEditor {
const pointHandles = const pointHandles =
LinearElementEditor.getPointsGlobalCoordinates(element); LinearElementEditor.getPointsGlobalCoordinates(element);
let idx = linearElementEditor.visiblePointIndexes.length; let counter = linearElementEditor.visiblePointIndexes.length;
// loop from right to left because points on the right are rendered over // loop from right to left because points on the right are rendered over
// points on the left, thus should take precedence when clicking, if they // points on the left, thus should take precedence when clicking, if they
// overlap // overlap
while (--idx > 0) { while (--counter >= 0) {
const point = pointHandles[linearElementEditor.visiblePointIndexes[idx]]; const index = linearElementEditor.visiblePointIndexes[counter];
const point = pointHandles[index];
if ( if (
distance2d(x, y, point[0], point[1]) * zoom.value < distance2d(x, y, point[0], point[1]) * zoom.value <
// +1px to account for outline stroke // +1px to account for outline stroke
LinearElementEditor.POINT_HANDLE_SIZE + 1 LinearElementEditor.POINT_HANDLE_SIZE + 1
) { ) {
return idx; return index;
} }
} }
return -1; return -1;