Choose the half of the viewport that keeps the anchor word visible.
Falls back to 'bottom' — the pre-existing behaviour — whenever there is no usable anchor, so a missing element never makes placement worse than before.
The word element the modal was opened for
'top' when the word sits in the lower half, otherwise 'bottom'
Choose the half of the viewport that keeps the anchor word visible.
Falls back to 'bottom' — the pre-existing behaviour — whenever there is no usable anchor, so a missing element never makes placement worse than before.