mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-24 00:01:03 +00:00
fix: clamp when seeking a non-zero unit between -1 and 1 (#1736)
This commit is contained in:
parent
491f8b8fb1
commit
87b159fb9d
1 changed files with 10 additions and 6 deletions
|
|
@ -13,13 +13,17 @@ end
|
|||
|
||||
function M:seek(units)
|
||||
local h = cx.active.current.hovered
|
||||
if h and h.url == self.file.url then
|
||||
local step = math.floor(units * self.area.h / 10)
|
||||
ya.manager_emit("peek", {
|
||||
math.max(0, cx.active.preview.skip + step),
|
||||
only_if = self.file.url,
|
||||
})
|
||||
if not h or h.url ~= self.file.url then
|
||||
return
|
||||
end
|
||||
|
||||
local step = math.floor(units * self.area.h / 10)
|
||||
step = step == 0 and ya.clamp(-1, units, 1) or step
|
||||
|
||||
ya.manager_emit("peek", {
|
||||
math.max(0, cx.active.preview.skip + step),
|
||||
only_if = self.file.url,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue