mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 00:31:04 +00:00
fix: image position calculation (#144)
This commit is contained in:
parent
c3bc8721f1
commit
cbe0fd5c73
1 changed files with 4 additions and 2 deletions
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue