MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / position

Function position

src/components/inputhints/index.js:187–211  ·  view source on GitHub ↗

* Update the position of the hint list * @param {boolean} append Append the list to the body or not

()

Source from the content-addressed store, hash-verified

185 * @param {boolean} append Append the list to the body or not
186 */
187 function position() {
188 const activeHint = $ul.get(".active");
189 const { firstElementChild } = $ul;
190 if (!activeHint && firstElementChild)
191 firstElementChild.classList.add("active");
192 const client = $input.getBoundingClientRect();
193 const inputTop = client.top - 5;
194 const inputBottom = client.bottom + 5;
195 const inputLeft = client.left;
196 const bottomHeight = window.innerHeight - inputBottom;
197 const mid = window.innerHeight / 2;
198
199 if (bottomHeight >= mid) {
200 $ul.classList.remove("bottom");
201 $ul.style.top = `${inputBottom}px`;
202 $ul.style.bottom = "auto";
203 } else {
204 $ul.classList.add("bottom");
205 $ul.style.top = "auto";
206 $ul.style.bottom = `${inputTop}px`;
207 }
208
209 $ul.style.left = `${inputLeft}px`;
210 $ul.style.width = `${client.width}px`;
211 }
212
213 /**
214 * Set hint items

Callers 2

onfocusFunction · 0.85
index.jsFile · 0.85

Calls 3

addMethod · 0.80
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected