Skip to content

Commit 04c9c2d

Browse files
authored
Merge pull request nubasedev#301 from mmomtchev/new-autoplace
New autoplace
2 parents 0a3a3a4 + a5734c9 commit 04c9c2d

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/components/SuggestionsDropdown.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,16 @@ export const SuggestionsDropdown: React.FunctionComponent<SuggestionsDropdownPro
4949
const style: React.CSSProperties = {};
5050
if (
5151
suggestionsAutoplace &&
52-
top +
53-
textAreaRef.current.getBoundingClientRect().top +
54-
textAreaRef.current.ownerDocument.defaultView.pageYOffset +
55-
caret.lineHeight * 1.5 * suggestions.length >
56-
vh
52+
top + textAreaRef.current.getBoundingClientRect().top > vh / 2
5753
)
58-
style.bottom = textAreaRef.current.offsetHeight - caret.top;
54+
style.bottom = textAreaRef.current.offsetHeight - top;
5955
else style.top = top;
6056

6157
if (
6258
suggestionsAutoplace &&
63-
left +
64-
textAreaRef.current.getBoundingClientRect().left +
65-
textAreaRef.current.ownerDocument.defaultView.pageXOffset +
66-
caret.lineHeight *
67-
0.6666 *
68-
Math.max.apply(
69-
Math,
70-
suggestions.map(x => x.preview.toString().length)
71-
) >
72-
vw
59+
left + textAreaRef.current.getBoundingClientRect().left > vw / 2
7360
)
74-
style.right = textAreaRef.current.offsetWidth - caret.left;
61+
style.right = textAreaRef.current.offsetWidth - left;
7562
else style.left = left;
7663

7764
return (

0 commit comments

Comments
 (0)