mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
fix: Now you can scroll only one scroll by one (without input race). Removed local scroll param.
case: Double scroll at one place, start scrolling on one direction, you can scroll another scroll on top of first scroll
This commit is contained in:
parent
205253c98d
commit
80e2392d24
@ -12,6 +12,9 @@ M.interest = {
|
|||||||
data.ON_SWIPE,
|
data.ON_SWIPE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Global on all scrolls
|
||||||
|
M.current_scroll = nil
|
||||||
|
|
||||||
|
|
||||||
function M.init(self, scroll_parent, input_zone, border)
|
function M.init(self, scroll_parent, input_zone, border)
|
||||||
self.node = helper.get_node(scroll_parent)
|
self.node = helper.get_node(scroll_parent)
|
||||||
@ -33,7 +36,6 @@ function M.init(self, scroll_parent, input_zone, border)
|
|||||||
|
|
||||||
self.input = {
|
self.input = {
|
||||||
touch = false,
|
touch = false,
|
||||||
scroll = false,
|
|
||||||
start_x = 0,
|
start_x = 0,
|
||||||
start_y = 0,
|
start_y = 0,
|
||||||
side = false,
|
side = false,
|
||||||
@ -198,7 +200,7 @@ end
|
|||||||
|
|
||||||
function M.update(self, dt)
|
function M.update(self, dt)
|
||||||
if self.input.touch then
|
if self.input.touch then
|
||||||
if self.input.scroll then
|
if M.current_scroll == self then
|
||||||
update_hand_scroll(self, dt)
|
update_hand_scroll(self, dt)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -274,7 +276,7 @@ function M.on_input(self, action_id, action)
|
|||||||
self.target.y = self.pos.y
|
self.target.y = self.pos.y
|
||||||
else
|
else
|
||||||
local dist = helper.distance(action.x, action.y, inp.start_x, inp.start_y)
|
local dist = helper.distance(action.x, action.y, inp.start_x, inp.start_y)
|
||||||
if not inp.scroll and dist >= settings.DEADZONE then
|
if not M.current_scroll and dist >= settings.DEADZONE then
|
||||||
local dx = math.abs(inp.start_x - action.x)
|
local dx = math.abs(inp.start_x - action.x)
|
||||||
local dy = math.abs(inp.start_y - action.y)
|
local dy = math.abs(inp.start_y - action.y)
|
||||||
if dx > dy then
|
if dx > dy then
|
||||||
@ -283,12 +285,12 @@ function M.on_input(self, action_id, action)
|
|||||||
inp.side = SIDE_Y
|
inp.side = SIDE_Y
|
||||||
end
|
end
|
||||||
-- Check scroll side if we can scroll
|
-- Check scroll side if we can scroll
|
||||||
if self.can_x and inp.side == SIDE_X or
|
if (self.can_x and inp.side == SIDE_X or
|
||||||
self.can_y and inp.side == SIDE_Y then
|
self.can_y and inp.side == SIDE_Y) then
|
||||||
inp.scroll = true
|
M.current_scroll = self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if inp.scroll then
|
if M.current_scroll == self then
|
||||||
add_delta(self, action.dx, action.dy)
|
add_delta(self, action.dx, action.dy)
|
||||||
result = true
|
result = true
|
||||||
end
|
end
|
||||||
@ -296,9 +298,9 @@ function M.on_input(self, action_id, action)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if action.released then
|
if action.released then
|
||||||
if inp.scroll then
|
if M.current_scroll == self then
|
||||||
inp.touch = false
|
inp.touch = false
|
||||||
inp.scroll = false
|
M.current_scroll = nil
|
||||||
inp.side = false
|
inp.side = false
|
||||||
result = true
|
result = true
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user