mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Add more infinity scroll example
This commit is contained in:
@@ -125,8 +125,10 @@ function M.get_index(self, pos)
|
||||
local col = (pos.x + self.border_offset.x) / (self.node_size.x + self.offset.x)
|
||||
local row = -(pos.y + self.border_offset.y) / (self.node_size.y + self.offset.y)
|
||||
|
||||
local index = col + (row * self.in_row) + 1
|
||||
return math.floor(index)
|
||||
row = math.floor(row)
|
||||
|
||||
local index = col + (row * self.in_row)
|
||||
return math.ceil(index)
|
||||
end
|
||||
|
||||
|
||||
|
@@ -23,7 +23,7 @@ function M:init(data_list, scroll, grid, create_function)
|
||||
self.components = {}
|
||||
|
||||
self.elements_view_count = vmath.vector3(
|
||||
math.ceil(self.view_size.x / self.prefab_size.x),
|
||||
math.min(math.ceil(self.view_size.x / self.prefab_size.x), self.grid.in_row),
|
||||
math.ceil(self.view_size.y / self.prefab_size.y),
|
||||
0)
|
||||
|
||||
@@ -89,8 +89,9 @@ end
|
||||
function M:_check_elements()
|
||||
local pos = gui.get_position(self.scroll.content_node)
|
||||
pos.y = -pos.y
|
||||
|
||||
local top_index = self.grid:get_index(pos)
|
||||
local last_index = top_index + (self.elements_view_count.x * self.elements_view_count.y) + 1
|
||||
local last_index = top_index + (self.elements_view_count.x * self.elements_view_count.y) + self.grid.in_row - 1
|
||||
|
||||
-- Clear outside elements
|
||||
for index, _ in pairs(self.nodes) do
|
||||
|
Reference in New Issue
Block a user