mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-02 08:01:47 -04:00
Fix overflow when zooming out of wide pdf (#119)
This commit is contained in:
+9
-2
@@ -220,8 +220,15 @@ impl Tui {
|
|||||||
img_area.width = img_area
|
img_area.width = img_area
|
||||||
.width
|
.width
|
||||||
.saturating_sub((zoom.level * 2).unsigned_abs())
|
.saturating_sub((zoom.level * 2).unsigned_abs())
|
||||||
.max((f32::from(img_area.height) * img_aspect_ratio) as u16);
|
.max(
|
||||||
img_area.x += (old_width - img_area.width) / 2;
|
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:#?}");
|
log::debug!("after adjustment, img_area is {img_area:#?}");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user