diff options
Diffstat (limited to 'static/hold.js')
| -rw-r--r-- | static/hold.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/static/hold.js b/static/hold.js index e937a25..9f2b8da 100644 --- a/static/hold.js +++ b/static/hold.js @@ -36,7 +36,8 @@ export function hold(btn, fire, { ms = HOLD_MS, tap } = {}) { e.stopPropagation(); btn.setPointerCapture(e.pointerId); btn.classList.add("holding"); - timer = setTimeout(() => { cancel(); buzz(); fire(); }, ms); + // A button redrawn away mid-hold has lost its pointerup: drop the hold. + timer = setTimeout(() => { const live = btn.isConnected; cancel(); if (live) { buzz(); fire(); } }, ms); }); btn.addEventListener("pointerup", () => { if (timer && tap) tap(); |
