mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 18:12:19 +02:00
#111 Add druid.stencil_check for auto stencil check to call set_click_zone
This commit is contained in:
@@ -61,7 +61,12 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local Scroll = component.create("scroll", { component.ON_INPUT, component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
|
||||
local Scroll = component.create("scroll", {
|
||||
component.ON_INPUT,
|
||||
component.ON_UPDATE,
|
||||
component.ON_LAYOUT_CHANGE,
|
||||
component.ON_LATE_INIT
|
||||
})
|
||||
|
||||
|
||||
local function inverse_lerp(min, max, current)
|
||||
@@ -172,6 +177,16 @@ function Scroll.init(self, view_node, content_node)
|
||||
end
|
||||
|
||||
|
||||
function Scroll.on_late_init(self)
|
||||
if not self.click_zone and const.IS_STENCIL_CHECK then
|
||||
local stencil_node = helper.get_closest_stencil_node(self.node)
|
||||
if stencil_node then
|
||||
self:set_click_zone(stencil_node)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Scroll.on_layout_change(self)
|
||||
gui.set_position(self.content_node, self.position)
|
||||
end
|
||||
|
Reference in New Issue
Block a user