mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +02:00
Update infinity list
This commit is contained in:
parent
6a44a7dcff
commit
03a00fe3d2
@ -184,7 +184,6 @@ function StaticGrid.add(self, item, index, shift_policy)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.nodes[index] = item
|
self.nodes[index] = item
|
||||||
|
|
||||||
gui.set_parent(item, self.parent)
|
gui.set_parent(item, self.parent)
|
||||||
|
|
||||||
-- Add new item instantly in new pos. Break update function for correct positioning
|
-- Add new item instantly in new pos. Break update function for correct positioning
|
||||||
|
@ -18,14 +18,12 @@ function M:init(data_list, scroll, grid, create_function)
|
|||||||
--- Current visual elements indexes
|
--- Current visual elements indexes
|
||||||
self.top_index = 1
|
self.top_index = 1
|
||||||
self.last_index = 1
|
self.last_index = 1
|
||||||
|
self.create_function = create_function
|
||||||
|
|
||||||
self._data = {}
|
self._data = {}
|
||||||
self._data_first_index = false
|
self._data_first_index = false
|
||||||
self._data_last_index = false
|
self._data_last_index = false
|
||||||
self._data_length = 0
|
self._data_length = 0
|
||||||
|
|
||||||
self.create_function = create_function
|
|
||||||
|
|
||||||
self._data_visual = {}
|
self._data_visual = {}
|
||||||
|
|
||||||
self.scroll.on_scroll:subscribe(self._check_elements, self)
|
self.scroll.on_scroll:subscribe(self._check_elements, self)
|
||||||
@ -165,8 +163,8 @@ function M:_check_elements()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:_check_elements_from(self.top_index - 1, -1)
|
self:_check_elements_from(self.top_index, -1)
|
||||||
self:_check_elements_from(self.top_index, 1)
|
self:_check_elements_from(self.top_index + 1, 1)
|
||||||
|
|
||||||
for index, data in pairs(self._data_visual) do
|
for index, data in pairs(self._data_visual) do
|
||||||
self.top_index = math.min(self.top_index or index, index)
|
self.top_index = math.min(self.top_index or index, index)
|
||||||
|
@ -118,6 +118,10 @@ local function setup_infinity_list(self)
|
|||||||
return create_infinity_instance_dynamic(self, record, index)
|
return create_infinity_instance_dynamic(self, record, index)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
timer.delay(1, false, function()
|
||||||
|
self.infinity_list_dynamic:scroll_to_index(25)
|
||||||
|
end)
|
||||||
|
|
||||||
self.infinity_list_dynamic_hor = self.druid:new_infinity_list(data, self.infinity_scroll_dynamic_hor, self.infinity_grid_dynamic_hor, function(record, index)
|
self.infinity_list_dynamic_hor = self.druid:new_infinity_list(data, self.infinity_scroll_dynamic_hor, self.infinity_grid_dynamic_hor, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
return create_infinity_instance_dynamic_hor(self, record, index)
|
return create_infinity_instance_dynamic_hor(self, record, index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user