fix: image position calculation (#144)

This commit is contained in:
三咲雅 · Misaki Masa 2023-09-13 01:13:10 +08:00 committed by GitHub
parent c3bc8721f1
commit cbe0fd5c73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,8 +39,10 @@ impl ManagerLayout {
pub fn preview_rect(&self) -> Rect {
let WindowSize { columns, rows, .. } = Term::size();
let x = (columns as u32 * (self.parent + self.current) / self.all) as u16;
let width = (columns as u32 * self.preview / self.all) as u16;
let width = (columns as u32 * self.preview) as f64 / self.all as f64;
let width = if width.fract() > 0.5 { width.ceil() as u16 } else { width.floor() as u16 };
let x = columns.saturating_sub(width);
Rect {
x: x.saturating_add(PREVIEW_BORDER / 2),