aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.js')
-rw-r--r--src/app.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/app.js b/src/app.js
index 0772d42..e0b2c04 100644
--- a/src/app.js
+++ b/src/app.js
@@ -809,7 +809,22 @@ function linkify(text) {
}
function tabBtn(label, active, onClick) {
- return h('button', { class: active ? 'active' : '', onClick }, label);
+ // Act on POINTERDOWN, not click: on a phone the click event lands
+ // 100–250ms after the finger does, and a tab switch has no scroll or
+ // long-press ambiguity to wait out — native segmented controls switch on
+ // touch-down for exactly this reason. The click handler stays for
+ // keyboard/AT activation; re-selecting the current tab is a no-op, so the
+ // pair firing together costs nothing.
+ let downAt = 0;
+ return h('button', {
+ class: active ? 'active' : '',
+ onPointerdown: (e) => {
+ if (e.button !== 0) return;
+ downAt = performance.now();
+ onClick();
+ },
+ onClick: () => { if (performance.now() - downAt > 500) onClick(); },
+ }, label);
}
function createPane() {