Skip to content

Commit

Permalink
fix: image position calculation (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi authored Sep 12, 2023
1 parent c3bc872 commit cbe0fd5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config/src/manager/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit cbe0fd5

Please sign in to comment.