Skip to content

Commit 8ad4fae

Browse files
Simplified getAnnotationBounds
1 parent 97ddea3 commit 8ad4fae

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

packages/text-annotator/src/state/TextAnnotationStore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface TextAnnotationStore<T extends TextAnnotation = TextAnnotation>
1313

1414
getAnnotationRects(id: string): DOMRect[];
1515

16-
getAnnotationBounds(id: string, hintX?: number, hintY?: number, buffer?: number): DOMRect | undefined;
16+
getAnnotationBounds(id: string): DOMRect | undefined;
1717

1818
getAnnotationRects(id: string): DOMRect[];
1919

packages/text-annotator/src/state/TextAnnotatorState.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,9 @@ export const createTextAnnotatorState = <I extends TextAnnotation = TextAnnotati
114114
return all ? filtered : filtered[0];
115115
}
116116

117-
const getAnnotationBounds = (id: string, x?: number, y?: number, buffer = 5): DOMRect | undefined => {
117+
const getAnnotationBounds = (id: string): DOMRect | undefined => {
118118
const rects = tree.getAnnotationRects(id);
119-
if (rects.length === 0) return;
120-
121-
if (x && y) {
122-
const match = rects.find(({ top, right, bottom, left }) =>
123-
x >= left - buffer && x <= right + buffer && y >= top - buffer && y <= bottom + buffer);
124-
125-
// Preferred bounds: the rectangle
126-
if (match) return match;
127-
}
128-
129-
return tree.getAnnotationBounds(id);
119+
return rects.length > 0 ? tree.getAnnotationBounds(id) : undefined;
130120
}
131121

132122
const getIntersecting = (

0 commit comments

Comments
 (0)