diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 396f30a..40d6dc8 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -64,6 +64,9 @@ kbd { .workspace { --left: 272px; --right: 280px; + /* The top bar keeps the width it has with both panels open, centred, whatever is open. */ + --bar-inset: calc(280px + 12px); + position: relative; display: grid; grid-template-columns: var(--left) 1fr; min-height: 0; @@ -112,6 +115,7 @@ kbd { @media (max-width: 820px) { .workspace, .workspace.has-selection { + --bar-inset: 12px; grid-template-columns: 1fr; grid-template-rows: 1fr 40%; } @@ -4489,9 +4493,10 @@ table.board { .top-dock { position: absolute; top: 10px; - left: 12px; - right: 12px; + left: var(--bar-inset); + right: var(--bar-inset); z-index: 30; + container-type: inline-size; pointer-events: none; } diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 4ae84b6..1975610 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -41,11 +41,11 @@ watch(
-
+ diff --git a/app/components/editor/BottomBar.vue b/app/components/editor/BottomBar.vue index 1b90341..1dc7433 100644 --- a/app/components/editor/BottomBar.vue +++ b/app/components/editor/BottomBar.vue @@ -31,12 +31,19 @@ const open = ref(null) const anchor = ref(0) let timer: ReturnType | undefined -function show(id: string, e: Event) { +const dock = ref() +/** Where the list opens: centred above the pointer, kept inside the canvas. */ +function anchorAt(x: number) { + const r = dock.value!.getBoundingClientRect() + const half = 130 + anchor.value = Math.min(Math.max(x - r.left, half), Math.max(half, r.width - half)) +} + +function show(id: string, e: PointerEvent) { clearTimeout(timer) - const el = e.currentTarget as HTMLElement const go = () => { + if (open.value !== id) anchorAt(e.clientX) open.value = id - anchor.value = el.offsetLeft + el.offsetWidth / 2 } // Moving along the bar switches at once; the first one waits a moment. if (open.value) go() @@ -52,13 +59,12 @@ function stay() { clearTimeout(timer) } -function toggle(id: string, e: Event) { +function toggle(id: string, e: MouseEvent) { if (open.value === id) open.value = null else { clearTimeout(timer) - const el = e.currentTarget as HTMLElement + anchorAt(e.clientX) open.value = id - anchor.value = el.offsetLeft + el.offsetWidth / 2 } } @@ -95,7 +101,7 @@ onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))