fix: clamp when seeking a non-zero unit between -1 and 1

This commit is contained in:
sxyazi 2024-10-05 22:30:09 +08:00
parent 491f8b8fb1
commit 2e30ebab73
No known key found for this signature in database

View file

@ -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