Need to opt-out of orient-top if there isn't space above
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user