PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Go to page keeps the side gutter clear of the quick-action bar (part of #2665)
Marco Arnulfob78724be05ea
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 136619a35..7747fdf00 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -2472,12 +2472,11 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {// to one side. A page already shown whole, or one filling the window's width, keeps the// scroll, so paging through a zoomed-in document stays on the same column. Otherwise a// page that fits is centred, and a wider one scrolled just far enough to fill the window.+ // The page counts with its side gutters, which keep its edge clear of the floating+ // quick-action bar as the layout does.let (x, w) = (view.last_scroll.x, avail.width());- let target = if r.width() <= w {- if r.left() >= x && r.right() <= x + w { x } else { r.center().x - w / 2.0 }- } else {- x.clamp(r.left(), r.right() - w)- };+ let (left, right) = (r.left() - SIDE, r.right() + SIDE);+ let target = if right - left <= w { if left >= x && right <= x + w { x } else { r.center().x - w / 2.0 } } else { x.clamp(left, right - w) };if (target - x).abs() > 0.5 {scroll = scroll.horizontal_scroll_offset(target.clamp(0.0, (content_w - w).max(0.0)));}