Scroll polishing

This commit is contained in:
Insality
2020-05-03 20:46:01 +03:00
parent 99781f333d
commit facfe39269
4 changed files with 51 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
local M = {}
local function init_grid(self)
local function init_scroll_with_grid(self)
local prefab = gui.get_node("grid_prefab")
local grid_scroll = self.druid:new_scroll("scroll_with_grid_size", "grid_content")
@@ -15,7 +15,6 @@ local function init_grid(self)
local button = self.druid:new_button(clone_prefab["grid_button"], function()
local position = gui.get_position(clone_prefab["grid_prefab"])
position.x = -position.x
grid_scroll:scroll_to(position)
end)
button:set_click_zone(gui.get_node("scroll_with_grid_size"))
@@ -26,7 +25,7 @@ local function init_grid(self)
grid_scroll:set_size(grid:get_size())
local scroll_slider = self.druid:new_slider("grid_scroll_pin", vmath.vector3(300, 0, 0), function(_, value)
-- grid_scroll:scroll_to_percent(vmath.vector3(value, 0, 0), true)
grid_scroll:scroll_to_percent(vmath.vector3(value, 0, 0), true)
end)
grid_scroll.on_scroll:subscribe(function(_, point)
@@ -36,19 +35,28 @@ end
function M.setup_page(self)
-- Usual scroll for whole page
self.druid:new_scroll("scroll_page", "scroll_page_content")
-- Simple scroll with no adjust
self.druid:new_scroll("simple_scroll_input", "simple_scroll_content")
-- scroll contain scrolls:
-- parent first
-- Scroll with grid example
init_scroll_with_grid(self)
-- Scroll contain children scrolls:
-- Parent scroll
self.druid:new_scroll("children_scroll", "children_scroll_content")
-- chilren next
-- Childre scrolls
self.druid:new_scroll("children_scroll_1", "children_scroll_content_1")
self.druid:new_scroll("children_scroll_2", "children_scroll_content_2")
self.druid:new_scroll("children_scroll_3", "children_scroll_content_3")
-- Content with less size than view
self.druid:new_scroll("scroll_smaller_view", "scroll_smaller_content")
:set_extra_strech_size(0)
-- Scroll with points of interests
self.druid:new_scroll("scroll_with_points", "scroll_with_points_content")
:set_points({
vmath.vector3(300, 0, 0),
@@ -56,8 +64,6 @@ function M.setup_page(self)
vmath.vector3(1500, 0, 0),
vmath.vector3(2100, 0, 0),
})
init_grid(self)
end