Need to opt-out of orient-top if there isn't space above

This commit is contained in:
Jason Zimdars
2025-10-30 13:57:20 -05:00
parent 4c7578c782
commit ec620f98a6
2 changed files with 10 additions and 1 deletions
@@ -4,7 +4,8 @@ export function orient(el, orient = true) {
const directions = [
["orient-left", spaceOnRight],
["orient-right", spaceOnLeft],
["orient-top", spaceOnBottom]
["orient-top", spaceOnBottom],
["orient-bottom", spaceOnTop]
];
directions.forEach(([className, fn]) =>
@@ -23,3 +24,7 @@ function spaceOnRight(el) {
function spaceOnBottom(el) {
return window.innerHeight - el.getBoundingClientRect().bottom
}
function spaceOnTop(el) {
return el.getBoundingClientRect().top
}