Update infinity list

This commit is contained in:
Insality 2021-04-01 21:58:46 +03:00
parent 6a44a7dcff
commit 03a00fe3d2
3 changed files with 7 additions and 6 deletions

View File

@ -184,7 +184,6 @@ function StaticGrid.add(self, item, index, shift_policy)
end
self.nodes[index] = item
gui.set_parent(item, self.parent)
-- Add new item instantly in new pos. Break update function for correct positioning

View File

@ -18,14 +18,12 @@ function M:init(data_list, scroll, grid, create_function)
--- Current visual elements indexes
self.top_index = 1
self.last_index = 1
self.create_function = create_function
self._data = {}
self._data_first_index = false
self._data_last_index = false
self._data_length = 0
self.create_function = create_function
self._data_visual = {}
self.scroll.on_scroll:subscribe(self._check_elements, self)
@ -165,8 +163,8 @@ function M:_check_elements()
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
self.top_index = math.min(self.top_index or index, index)

View File

@ -118,6 +118,10 @@ local function setup_infinity_list(self)
return create_infinity_instance_dynamic(self, record, index)
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)
-- function should return gui_node, [druid_component]
return create_infinity_instance_dynamic_hor(self, record, index)