mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: IFrame and elbow arrow interaction fix (#9101)
This commit is contained in:
parent
b0c8c5f7a7
commit
9e49c9254b
3 changed files with 46 additions and 59 deletions
|
@ -1,8 +1,3 @@
|
|||
import { isIframeElement } from "../element/typeChecks";
|
||||
import type {
|
||||
ExcalidrawIframeElement,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "../element/types";
|
||||
import type { ElementOrToolType } from "../types";
|
||||
|
||||
export const hasBackground = (type: ElementOrToolType) =>
|
||||
|
@ -47,51 +42,3 @@ export const canChangeRoundness = (type: ElementOrToolType) =>
|
|||
export const toolIsArrow = (type: ElementOrToolType) => type === "arrow";
|
||||
|
||||
export const canHaveArrowheads = (type: ElementOrToolType) => type === "arrow";
|
||||
|
||||
export const getElementAtPosition = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean,
|
||||
) => {
|
||||
let hitElement = null;
|
||||
// We need to to hit testing from front (end of the array) to back (beginning of the array)
|
||||
// because array is ordered from lower z-index to highest and we want element z-index
|
||||
// with higher z-index
|
||||
for (let index = elements.length - 1; index >= 0; --index) {
|
||||
const element = elements[index];
|
||||
if (element.isDeleted) {
|
||||
continue;
|
||||
}
|
||||
if (isAtPositionFn(element)) {
|
||||
hitElement = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hitElement;
|
||||
};
|
||||
|
||||
export const getElementsAtPosition = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
isAtPositionFn: (element: NonDeletedExcalidrawElement) => boolean,
|
||||
) => {
|
||||
const iframeLikes: ExcalidrawIframeElement[] = [];
|
||||
const elementsAtPosition: NonDeletedExcalidrawElement[] = [];
|
||||
// We need to to hit testing from front (end of the array) to back (beginning of the array)
|
||||
// because array is ordered from lower z-index to highest and we want element z-index
|
||||
// with higher z-index
|
||||
for (let index = elements.length - 1; index >= 0; --index) {
|
||||
const element = elements[index];
|
||||
if (element.isDeleted) {
|
||||
continue;
|
||||
}
|
||||
if (isIframeElement(element)) {
|
||||
iframeLikes.push(element);
|
||||
continue;
|
||||
}
|
||||
if (isAtPositionFn(element)) {
|
||||
elementsAtPosition.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
return elementsAtPosition.concat(iframeLikes);
|
||||
};
|
||||
|
|
|
@ -12,8 +12,6 @@ export {
|
|||
hasStrokeStyle,
|
||||
canHaveArrowheads,
|
||||
canChangeRoundness,
|
||||
getElementAtPosition,
|
||||
getElementsAtPosition,
|
||||
} from "./comparisons";
|
||||
export {
|
||||
getNormalizedZoom,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue