Let scrollbar only scroll to whole row numbers

This commit is contained in:
Max
2026-06-01 05:19:36 +02:00
parent 0a9380cd22
commit 991bc5eb3e
+7 -3
View File
@@ -470,9 +470,13 @@ local function runScrollableGrid(options)
targetScrollRow = tonumber(initialTargetRow) or currentScrollRow
end
local function snapScrollRow(row)
return math.floor((tonumber(row) or 0) + 0.5)
end
local function persistScrollState()
if options.setScrollState then
options.setScrollState(currentScrollRow, targetScrollRow)
options.setScrollState(snapScrollRow(targetScrollRow), snapScrollRow(targetScrollRow))
end
end
@@ -503,7 +507,7 @@ local function runScrollableGrid(options)
end
local function scrollTo(row)
local clampedRow = clampScrollRow(row)
local clampedRow = clampScrollRow(snapScrollRow(row))
if clampedRow ~= targetScrollRow then
targetScrollRow = clampedRow
@@ -520,7 +524,7 @@ local function runScrollableGrid(options)
totalRows = math.ceil(#entries / columns)
maxScrollRow = math.max(0, totalRows - rowsPerView)
currentScrollRow = clampScrollRow(currentScrollRow)
targetScrollRow = clampScrollRow(targetScrollRow)
targetScrollRow = clampScrollRow(snapScrollRow(targetScrollRow))
persistScrollState()
local firstVisibleRow = math.floor(currentScrollRow)