Let scrollbar only scroll to whole row numbers
This commit is contained in:
+7
-3
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user