* Update the position of the hint list * @param {boolean} append Append the list to the body or not
()
| 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 |