aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/app.js b/src/app.js
index 0b05913..537ba0d 100644
--- a/src/app.js
+++ b/src/app.js
@@ -6402,7 +6402,7 @@ if (INTENT_URI) {
let v = 0, acc = 0, raf = 0, last = 0;
const stop = () => { v = 0; acc = 0; if (raf) cancelAnimationFrame(raf); raf = 0; };
const tick = (now) => {
- const dt = Math.min(40, now - last); last = now;
+ const dt = Math.max(0, Math.min(40, now - last)); last = Math.max(last, now); // a frame stamp can predate the push
acc += v * dt;
const step = Math.trunc(acc);
if (step) {
@@ -6446,10 +6446,12 @@ if (INTENT_URI) {
document.addEventListener('pointermove', (e) => {
if (!drag) return;
if (!(e.buttons & 1)) { drag = null; return; }
+ if (drag.sel) return;
if (!drag.on) {
const dx = Math.abs(e.clientX - drag.x), dy = Math.abs(e.clientY - drag.y);
if (dx < 6 && dy < 6) return;
- if (dx > dy) { drag = null; return; } // sideways: selecting text
+ // clearly sideways: selecting text (and still not a click on the post)
+ if (dx > 2 * dy) { drag.sel = true; return; }
drag.on = true;
document.documentElement.classList.add('grab-scrolling');
try { getSelection().removeAllRanges(); } catch {}
@@ -6462,14 +6464,17 @@ if (INTENT_URI) {
const end = (e) => {
if (!drag) return;
const d = drag; drag = null;
- if (!d.on) return;
- document.documentElement.classList.remove('grab-scrolling');
- const p = d.pts, a = p[0], b = p[p.length - 1];
- // released while moving: throw it; held still first: just let go
- if (a && b && b[0] > a[0] && e.timeStamp - b[0] < 60) coast((a[1] - b[1]) / (b[0] - a[0]) * 1.2);
+ if (!d.on && !d.sel) return;
+ if (d.on) {
+ document.documentElement.classList.remove('grab-scrolling');
+ const p = d.pts, a = p[0], b = p[p.length - 1];
+ // released while moving: throw it; held still first: just let go
+ if (a && b && b[0] > a[0] && e.timeStamp - b[0] < 60) coast((a[1] - b[1]) / (b[0] - a[0]) * 1.2);
+ }
+ // the press moved: what it started on isn't opened (Chrome still clicks it)
const eat = (ev) => { ev.stopPropagation(); ev.preventDefault(); };
document.addEventListener('click', eat, { capture: true, once: true });
- setTimeout(() => document.removeEventListener('click', eat, { capture: true }), 0);
+ setTimeout(() => document.removeEventListener('click', eat, { capture: true }), 300);
};
document.addEventListener('pointerup', end);
document.addEventListener('pointercancel', () => { if (drag?.on) document.documentElement.classList.remove('grab-scrolling'); drag = null; });