From ac71f3406bb294c83e6ad73ba9661192c9c04b99 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Thu, 24 Sep 2026 01:09:29 -0700 Subject: [PATCH] fix: stop scrolling at the topmost and leftmost page content Scrolling allowed 36 pt of blank page above and left of the furthest object, so a page like one with an Ivy background image placed at (-27, -3.6) could be scrolled past its top. OneNote 2010 stops exactly at the page origin or at the object furthest above or left of it, and opens the page there. The far edges keep their 36 pt margin. Assisted-by: claude-opus-5 --- crates/snowbound/src/scroll.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/snowbound/src/scroll.rs b/crates/snowbound/src/scroll.rs index f36116a9dfe8918b093b1fe8f7a5d4c41653496e..18cbcebfe159945944c2edece9ed17f1228e848a 100644 --- a/crates/snowbound/src/scroll.rs +++ b/crates/snowbound/src/scroll.rs @@ -15,8 +15,9 @@ impl Scroll { max[axis] = max[axis].max(rect[axis + 2]); } } + // OneNote stops at the page origin or the object furthest above or left of it. for axis in 0..2 { - min[axis] = (min[axis] - 36.0) * viewport.scale; + min[axis] *= viewport.scale; max[axis] = ((max[axis] + 36.0) * viewport.scale - viewport.size[axis] as f32).max(min[axis]); } @@ -100,7 +101,7 @@ mod tests { }; let scroll = Scroll::new(viewport, [[-80.0, -20.0, 1000.0, 1200.0]].into_iter()); scroll.clamp(&mut viewport); - assert_eq!(viewport.origin, [232.0, 112.0]); + assert_eq!(viewport.origin, [160.0, 40.0]); viewport.origin = [-9999.0; 2]; scroll.clamp(&mut viewport); assert_eq!(viewport.origin, [-1272.0, -1872.0]); -- 2.54.0