Repository: excalidraw/excalidraw
File: src/element/transformHandles.ts (TypeScript)

Code before:
  // you can't move/resize
  if (element.locked) {
    return {};
  }

  let omitSides: { [T in TransformHandleType]?: boolean } = {};
  if (element.type === "freedraw" || isLinearElement(element)) {
    if (element.points.length === 2) {
      // only check the last point because starting point is always (0,0)
      const [, p1] = element.points;
      if (p1[0] === 0 || p1[1] === 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      } else if (p1[0] > 0 && p1[1] < 0) {
        omitSides = OMIT_SIDES_FOR_LINE_SLASH;
      } else if (p1[0] > 0 && p1[1] > 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      } else if (p1[0] < 0 && p1[1] > 0) {
        omitSides = OMIT_SIDES_FOR_LINE_SLASH;
      } else if (p1[0] < 0 && p1[1] < 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      }
    }
  } else if (isTextElement(element)) {
    omitSides = OMIT_SIDES_FOR_TEXT_ELEMENT;
  }
  const dashedLineMargin = isLinearElement(element) ? 12 : 4;
  return getTransformHandlesFromCoords(
    getElementAbsoluteCoords(element),
    element.angle,
    zoom,
    pointerType,
    omitSides,
    dashedLineMargin,
  );
};

export const shouldShowBoundingBox = (
  elements: NonDeletedExcalidrawElement[],
) => {
  if (elements.length > 1) {
    return true;
  }
  const element = elements[0];
  if (!isLinearElement(element)) {
    return true;
  }

  const points = LinearElementEditor.getPointsGlobalCoordinates(element);
  if (points.length > 2) {
    return true;
  }

Review comment (suggestion):
is the `12` in any way related to the `8` we use in rendering? Also, I know we'll be removing it soon, but I'd use constants for these so we can later easily find all occurrences to replace.

Code after:
  // you can't move/resize
  if (element.locked) {
    return {};
  }

  let omitSides: { [T in TransformHandleType]?: boolean } = {};
  if (element.type === "freedraw" || isLinearElement(element)) {
    if (element.points.length === 2) {
      // only check the last point because starting point is always (0,0)
      const [, p1] = element.points;
      if (p1[0] === 0 || p1[1] === 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      } else if (p1[0] > 0 && p1[1] < 0) {
        omitSides = OMIT_SIDES_FOR_LINE_SLASH;
      } else if (p1[0] > 0 && p1[1] > 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      } else if (p1[0] < 0 && p1[1] > 0) {
        omitSides = OMIT_SIDES_FOR_LINE_SLASH;
      } else if (p1[0] < 0 && p1[1] < 0) {
        omitSides = OMIT_SIDES_FOR_LINE_BACKSLASH;
      }
    }
  } else if (isTextElement(element)) {
    omitSides = OMIT_SIDES_FOR_TEXT_ELEMENT;
  }
  const dashedLineMargin = isLinearElement(element)
    ? DEFAULT_SPACING * 3
    : DEFAULT_SPACING;
  return getTransformHandlesFromCoords(
    getElementAbsoluteCoords(element),
    element.angle,
    zoom,
    pointerType,
    omitSides,
    dashedLineMargin,
  );
};

export const shouldShowBoundingBox = (
  elements: NonDeletedExcalidrawElement[],
) => {
  if (elements.length > 1) {
    return true;
  }
  const element = elements[0];
  if (!isLinearElement(element)) {
    return true;
  }

  return element.points.length > 2;
};