Solve #73 fix scroll drag on stretch/zoom nodes

This commit is contained in:
Insality
2022-04-10 15:20:57 +03:00
parent f7e6888c5a
commit decb9fd9fd
5 changed files with 147 additions and 14 deletions

View File

@@ -186,6 +186,8 @@ function Drag.init(self, node, on_drag_callback)
self.on_drag_start = Event()
self.on_drag = Event(on_drag_callback)
self.on_drag_end = Event()
self:on_window_resized()
end
@@ -199,6 +201,13 @@ function Drag.on_late_init(self)
end
function Drag.on_window_resized(self)
local x_koef, y_koef = helper.get_screen_aspect_koef()
self._x_koef = x_koef
self._y_koef = y_koef
end
function Drag.on_input_interrupt(self)
if self.is_drag or self.is_touch then
end_touch(self)
@@ -258,8 +267,8 @@ function Drag.on_input(self, action_id, action)
local touch_modified = find_touch(action_id, action, self.touch_id)
if touch_modified and self.is_drag then
self.dx = touch_modified.x - self.x
self.dy = touch_modified.y - self.y
self.dx = (touch_modified.x - self.x) * self._x_koef
self.dy = (touch_modified.y - self.y) * self._y_koef
end
if touch_modified then