From 8066a226f3ac6df3b5e591384a127ba8d81f2700 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 16:37:43 +0100 Subject: web: keep browser from stealing the pinch gesture Firefox on Android may consume two-finger pinch for page zooming despite touch-action: none on the canvas. Disable page zooming via the viewport meta (maximum-scale=1, user-scalable=no) so the gesture reaches the app as pointer events; the app provides its own zoom. Also join touch pointers seen only via pointermove into the pointer table, so a swallowed second pointerdown cannot break pinch. --- crates/wipfel/index.html | 2 +- crates/wipfel/src/canvas_view.rs | 12 ++++++++++-- crates/wipfel/www/index.html | 2 +- dist/wipfel/index.html | 2 +- dist/wipfel/wipfel.js | 11 +++++++++++ dist/wipfel/wipfel_bg.wasm | Bin 508958 -> 509301 bytes 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/wipfel/index.html b/crates/wipfel/index.html index d00adbe..2da0c81 100644 --- a/crates/wipfel/index.html +++ b/crates/wipfel/index.html @@ -2,7 +2,7 @@ - + wipfel — web based gipfel photogrammetry diff --git a/crates/wipfel/src/canvas_view.rs b/crates/wipfel/src/canvas_view.rs index b962f17..ac1d6ab 100644 --- a/crates/wipfel/src/canvas_view.rs +++ b/crates/wipfel/src/canvas_view.rs @@ -432,8 +432,16 @@ pub fn canvas_view(props: &Props) -> Html { // update the pointer table and handle two-finger pinch let pinch_ev = { let mut d = drag.borrow_mut(); - if let Some(p) = d.pts.iter_mut().find(|(id, _)| *id == e.pointer_id()) { - p.1 = (e.client_x() as f64, e.client_y() as f64); + let pos = (e.client_x() as f64, e.client_y() as f64); + match d.pts.iter_mut().find(|(id, _)| *id == e.pointer_id()) { + Some(p) => p.1 = pos, + // a touch pointermove for a pointer we never saw go + // down (lost pointerdown, e.g. swallowed by the + // browser) — join it so pinch still works + None if e.pointer_type() == "touch" && e.buttons() != 0 => { + d.pts.push((e.pointer_id(), pos)); + } + None => {} } if d.pts.len() >= 2 { let (x1, y1) = d.pts[0].1; diff --git a/crates/wipfel/www/index.html b/crates/wipfel/www/index.html index 5297a72..98f81e8 100644 --- a/crates/wipfel/www/index.html +++ b/crates/wipfel/www/index.html @@ -2,7 +2,7 @@ - + wipfel — web based gipfel photogrammetry diff --git a/dist/wipfel/index.html b/dist/wipfel/index.html index 5297a72..98f81e8 100644 --- a/dist/wipfel/index.html +++ b/dist/wipfel/index.html @@ -2,7 +2,7 @@ - + wipfel — web based gipfel photogrammetry diff --git a/dist/wipfel/wipfel.js b/dist/wipfel/wipfel.js index 9119aea..d312617 100644 --- a/dist/wipfel/wipfel.js +++ b/dist/wipfel/wipfel.js @@ -61,6 +61,10 @@ function __wbg_get_imports() { const ret = arg0.buffer; return ret; }, + __wbg_buttons_de1e6c7f6de70736: function(arg0) { + const ret = arg0.buttons; + return ret; + }, __wbg_cache_key_21c521bc3dd66e9b: function(arg0) { const ret = arg0.__yew_subtree_cache_key; return isLikeNone(ret) ? Number.MAX_SAFE_INTEGER : (ret) >>> 0; @@ -403,6 +407,13 @@ function __wbg_get_imports() { const ret = arg0.pointerId; return ret; }, + __wbg_pointerType_2e8b8270da489520: function(arg0, arg1) { + const ret = arg1.pointerType; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }, __wbg_preventDefault_af59afb0f0a02e20: function(arg0) { arg0.preventDefault(); }, diff --git a/dist/wipfel/wipfel_bg.wasm b/dist/wipfel/wipfel_bg.wasm index c89fbba..cc56f90 100644 Binary files a/dist/wipfel/wipfel_bg.wasm and b/dist/wipfel/wipfel_bg.wasm differ -- cgit v1.2.3