diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/app.js | 15 | ||||
| -rw-r--r-- | static/deck.css | 3 |
2 files changed, 14 insertions, 4 deletions
diff --git a/static/app.js b/static/app.js index 61e094b..8c6d4e2 100644 --- a/static/app.js +++ b/static/app.js @@ -298,12 +298,16 @@ function stepTab(dir) { if (at !== -1 && next >= 0 && next < names.length) showTab(names[next]); } -// Swipe the content sideways to change tab; gestures on sliders and buttons -// (including the card drag handles) are theirs, not the shell's. +// Swipe the content sideways to change tab, from anywhere but sliders and +// the dashboard's drag and resize handles, whose sideways drags are theirs. +// #tab-body is `touch-action: pan-y`: otherwise the browser claims the moving +// finger as a pan and sends pointercancel, which is why swipes never worked. +// A swipe that started on a button must not also click it. let swipe = null; +let swallowClick = false; tabBody.addEventListener("pointerdown", (e) => { if (e.pointerType === "mouse" && e.buttons !== 1) return; - if (e.target.closest("input, select, textarea, button")) { + if (e.target.closest("input, select, textarea, .panel-drag, .ui-resizable-handle")) { swipe = null; return; } @@ -315,8 +319,13 @@ tabBody.addEventListener("pointerup", (e) => { const dy = e.clientY - swipe.y; swipe = null; if (Math.abs(dx) < 70 || Math.abs(dx) < Math.abs(dy) * 1.5) return; + swallowClick = true; + setTimeout(() => { swallowClick = false; }, 0); stepTab(dx < 0 ? 1 : -1); }); +tabBody.addEventListener("click", (e) => { + if (swallowClick) { e.stopPropagation(); e.preventDefault(); } +}, true); tabBody.addEventListener("pointercancel", () => { swipe = null; }); // theme.css is rendered per request from UDT's live files, so re-reading it diff --git a/static/deck.css b/static/deck.css index 1ec72b6..0929684 100644 --- a/static/deck.css +++ b/static/deck.css @@ -78,7 +78,7 @@ body { .tabs button .nf { font-size: 1.5rem; line-height: 1; margin-right: 6px; } /* the glyphs draw past their advance */ .tabs button:not(.active):not(.named) span { display: none; } -#tab-body { flex: 1; min-height: 0; overflow: auto; } +#tab-body { flex: 1; min-height: 0; overflow: auto; touch-action: pan-y; } /* sideways moves stay ours: the swipe */ .tab-panel { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); @@ -429,6 +429,7 @@ select { .deck-btn:active { background: var(--udt-surface1); } .deck-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; } +.deck-cols[hidden] { display: none; } @media (max-width: 900px) { .deck-cols { grid-template-columns: 1fr; } } .deck-block { |
