Remove orientation on dialog close

This commit is contained in:
Andy Smith
2025-08-18 11:08:17 -05:00
parent 78273898d2
commit bb53258286
2 changed files with 11 additions and 4 deletions
+10 -4
View File
@@ -1,9 +1,15 @@
const EDGE_THRESHOLD = 16
export function orient(el) {
el.classList.toggle("orient-left", spaceOnRight(el) < EDGE_THRESHOLD)
el.classList.toggle("orient-right", spaceOnLeft(el) < EDGE_THRESHOLD)
el.classList.toggle("orient-top", spaceOnBottom(el) < EDGE_THRESHOLD)
export function orient(el, orient = true) {
const directions = [
["orient-left", spaceOnRight],
["orient-right", spaceOnLeft],
["orient-top", spaceOnBottom]
];
directions.forEach(([className, fn]) =>
el.classList[orient && fn(el) < EDGE_THRESHOLD ? "add" : "remove"](className)
);
}
function spaceOnLeft(el) {