mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Feature/scroll (#22)
* base scroll implementation * add scroll collection example mofidy scrolls, fix callback calls * unhover button if start swipe notify input components on swipe * add node center offset, calc by pivots modify with with node center scroll (to correct scroll to point) * Refactor, add some docs * fix: set_pos on end on scroll * add gui.animate speed in settings
This commit is contained in:
@@ -14,6 +14,7 @@ M.comps = {
|
||||
timer = require("druid.base.timer"),
|
||||
progress = require("druid.base.progress"),
|
||||
grid = require("druid.base.grid"),
|
||||
scroll = require("druid.base.scroll"),
|
||||
|
||||
progress_rich = require("druid.rich.progress_rich"),
|
||||
}
|
||||
@@ -72,7 +73,7 @@ local function create(module, factory)
|
||||
end
|
||||
factory[v][#factory[v] + 1] = instance
|
||||
|
||||
if v == data.ON_INPUT then
|
||||
if v == data.ON_INPUT or v == data.ON_SWIPE then
|
||||
input_init(factory)
|
||||
end
|
||||
end
|
||||
@@ -112,6 +113,19 @@ function _factory.on_message(factory, message_id, message, sender)
|
||||
end
|
||||
|
||||
|
||||
local function notify_input_on_swipe(factory)
|
||||
if factory[data.ON_INPUT] then
|
||||
local len = #factory[data.ON_INPUT]
|
||||
for i = len, 1, -1 do
|
||||
local comp = factory[data.ON_INPUT][i]
|
||||
if comp.on_swipe then
|
||||
comp:on_swipe()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Called ON_INPUT
|
||||
function _factory.on_input(factory, action_id, action)
|
||||
if factory[data.ON_SWIPE] then
|
||||
@@ -122,6 +136,7 @@ function _factory.on_input(factory, action_id, action)
|
||||
result = result or v:on_input(action_id, action)
|
||||
end
|
||||
if result then
|
||||
notify_input_on_swipe(factory)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user