← Commit history

adom-video: measure double-clicks (300 ms, 10 px) instead of the OS's 500 ms window, so pause-then-unpause no longer goes fullscreen

John Lauer ·bc550f7a72 ·1d ago ·parent 7f6b709
1 file changed +6−1
widgets/video-widget.js+6−1
@@ -847,9 +847,14 @@           tapTimer = setTimeout(() => { if (p.classList.contains('hide-ui')) this._show(); else this.toggle(); }, 280);           return;         }+        // a double-click is measured here, not left to the OS setting (Windows allows 500 ms, so a pause+        // then a quick unpause counted): two clicks within 300 ms and 10 px. Each click still toggles, as on+        // YouTube, so a double-click ends where it started and goes fullscreen.         this.toggle();+        const now = performance.now(), last = this._lastClick;+        if (last && now - last.t <= 300 && Math.hypot(e.clientX - last.x, e.clientY - last.y) <= 10) { this._lastClick = null; this.fullscreen(); }+        else this._lastClick = { t: now, x: e.clientX, y: e.clientY };       });-      click.addEventListener('dblclick', (e) => { e.preventDefault(); this.fullscreen(); });       $('.big').addEventListener('click', () => this.toggle());        p.addEventListener('pointermove', (e) => { if (e.pointerType !== 'touch') this._show(); });