godot-mota/src/utils/TouchScrollContainer.gd

27 lines
574 B
GDScript3
Raw Normal View History

2020-09-03 23:05:18 +08:00
extends ScrollContainer
var isDrag = false
var startPos = 0
var dragDir = 0
2020-09-04 12:13:48 +08:00
func _ready():
set_process_input(false)
2020-09-03 23:05:18 +08:00
func _input(event):
if event is InputEventMouseButton:
if event.button_index != BUTTON_LEFT:
return
if event.is_pressed():
isDrag = true
startPos = event.position.y
if !event.is_pressed():
isDrag = false
startPos = 0
if event is InputEventMouseMotion and isDrag:
var offset = event.position.y - startPos
self.scroll_vertical -= offset
startPos = event.position.y
2020-09-04 12:13:48 +08:00
func _on_BookDialog_popup_hide():
set_process_input(false)