aboutsummaryrefslogtreecommitdiff
path: root/touch_item_list/touch_item_list.gd
diff options
context:
space:
mode:
Diffstat (limited to 'touch_item_list/touch_item_list.gd')
-rw-r--r--touch_item_list/touch_item_list.gd13
1 files changed, 9 insertions, 4 deletions
diff --git a/touch_item_list/touch_item_list.gd b/touch_item_list/touch_item_list.gd
index 8b79431..67f88d7 100644
--- a/touch_item_list/touch_item_list.gd
+++ b/touch_item_list/touch_item_list.gd
@@ -1,12 +1,13 @@
extends ItemList
class_name TouchItemList
-const POINTER_VELOCITY_DECAYING_FACTOR: float = 2.5
-const POINTER_VELOCITY_BOOST_FACTOR: float = 1.5
+const POINTER_VELOCITY_DECAYING_FACTOR: float = PI
+const POINTER_VELOCITY_BOOST_FACTOR: float = 1.25
const EXACT_SELECTION: bool = false
var is_pointer_dragging := false
var pointer_drag_velocity := 0.0
+var when_last_dragged := 0
onready var sensor := get_node("sensor") as PointerInputSensor
onready var v_scroll_bar := get_v_scroll() as ScrollBar
@@ -37,13 +38,17 @@ func pointer_input_on_drag_handler(pointer: PointerInputSensor.PointerInputData)
var reported_velocity_abs := abs(pointer.velocity.y)
var relative_velocity := pointer.relative_position.y * Engine.get_frames_per_second()
var relative_velocity_abs := abs(relative_velocity)
- var max_velocity := pointer.velocity.y if reported_velocity_abs > relative_velocity_abs else relative_velocity
- pointer_drag_velocity = max_velocity * POINTER_VELOCITY_BOOST_FACTOR
+ pointer_drag_velocity = pointer.velocity.y if reported_velocity_abs > relative_velocity_abs else relative_velocity
v_scroll_bar.value -= pointer.relative_position.y
+ when_last_dragged = OS.get_ticks_msec()
func pointer_input_on_end_drag_handler(pointer: PointerInputSensor.PointerInputData):
is_pointer_dragging = false
+ if OS.get_ticks_msec() - when_last_dragged > 20:
+ pointer_drag_velocity = 0.0
+ else:
+ pointer_drag_velocity *= POINTER_VELOCITY_BOOST_FACTOR
func pointer_input_on_click_handler(pointer: PointerInputSensor.PointerInputData):