From 0992b9bc0ebdfb808c0395f99918b69a3c16dfbd Mon Sep 17 00:00:00 2001 From: Harald Date: Sun, 25 Oct 2026 11:15:32 +0100 Subject: [PATCH] fix: keep the measured swipe when the view touches the notebook edge (Issue #28) Clamping the continuous or endless view reset the fling while the finger was still down, so the release measured 0 px/s. Only an active glide stops there now. The fling diagnostics also log moves, path length and the time since the last move. Co-Authored-By: Claude Opus 5.5 --- src/main.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 20594f8..b8dc61d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1428,6 +1428,8 @@ fn main() -> Result<(), Box> { // Langes Drücken mit einem Finger öffnet das Kontextmenü let mut long_press = ui::LongPress::default(); let mut touch_pan_last_pos = (0.0_f32, 0.0_f32); + // Diagnostics for the fling: moves, path length (px) and time of the last move of this swipe + let mut touch_pan_trace: (u32, f32, Option) = (0, 0.0, None); // Nachgleiten nach schnellem Wischen mit dem Finger (Issue #28) let mut fling = ink_notes::viewport::Fling::default(); // Diagnosis for Issue #28: log every finger lift and the swipe speed @@ -3047,6 +3049,7 @@ fn main() -> Result<(), Box> { // Standard: 1 Finger scrollt / verschiebt den Canvas (Pan) is_touch_panning = true; touch_pan_last_pos = (tx, ty); + touch_pan_trace = (0, 0.0, None); } else { // Modus Finger-Zeichnen aktiv focus_page_at!((tx, ty)); @@ -3123,6 +3126,9 @@ fn main() -> Result<(), Box> { touch_pan_last_pos = (tx, ty); canvas.pan(dx, dy); fling.track(Vec2::new(dx, dy), Instant::now()); + touch_pan_trace.0 += 1; + touch_pan_trace.1 += Vec2::new(dx, dy).length(); + touch_pan_trace.2 = Some(Instant::now()); window.request_redraw(); } else if is_touch_drawing { current_pressure = pressure; @@ -3184,10 +3190,12 @@ fn main() -> Result<(), Box> { fling.track(Vec2::new(dx, dy), Instant::now()); let velocity = fling.release(Instant::now()); if debug_fling { + let (moves, path, last_move) = touch_pan_trace; eprintln!( - "[Nachgleiten] {:.0} px/s beim Abheben, gleitet: {}", + "[Nachgleiten] {:.0} px/s beim Abheben, gleitet: {} ({moves} Bewegungen, {path:.0} px, letzte vor {} ms)", velocity.length(), - fling.is_active() + fling.is_active(), + last_move.map_or(-1, |t| t.elapsed().as_millis() as i64) ); } window.request_redraw(); @@ -3255,13 +3263,14 @@ fn main() -> Result<(), Box> { // schreibt, bleibt dort, bis wieder gescrollt wird (Undo betrifft sie). canvas.set_fit_box(notebook.fit_box()); if notebook.is_endless() { - if canvas.clamp_endless(notebook.current_page().endless_scroll_limit()) { + if canvas.clamp_endless(notebook.current_page().endless_scroll_limit()) && fling.is_active() { fling.stop(); } } else if ui_state.continuous_scroll { let stack = notebook.page_stack(); - if canvas.clamp_scroll(&stack) { - // Am Anfang oder Ende des Notizbuchs angekommen + if canvas.clamp_scroll(&stack) && fling.is_active() { + // Am Anfang oder Ende des Notizbuchs angekommen (only a glide stops + // here; a finger still on the screen keeps its measured swipe) fling.stop(); } // Unabhängig von der Bezugsseite: Lage bezogen auf die erste Seite