Fix overflow when zooming out of wide pdf (#119)

This commit is contained in:
Max
2025-11-27 19:33:50 +01:00
committed by GitHub
parent 065797ccf6
commit 3dc5135a8b
+9 -2
View File
@@ -220,8 +220,15 @@ impl Tui {
img_area.width = img_area
.width
.saturating_sub((zoom.level * 2).unsigned_abs())
.max((f32::from(img_area.height) * img_aspect_ratio) as u16);
img_area.x += (old_width - img_area.width) / 2;
.max(
old_width
.min((f32::from(img_area.height) * img_aspect_ratio) as u16)
);
img_area.x += old_width
.checked_sub(img_area.width)
.expect("Zooming out shrinks the image")
/ 2;
log::debug!("after adjustment, img_area is {img_area:#?}");