aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2024-08-06 21:42:01 +0200
committernokoe <nokoe@mailbox.org>2024-08-06 21:43:19 +0200
commitbe7e809a7c4a9df2b64b1fc5d6e939c0c5b9f448 (patch)
treea3cc089e7951145122a2a5a5467f914a5ff0b8fb /client
parentbb19bbc0ec5b44585a0aa377ca0beef94e38f5e4 (diff)
downloadhurrycurry-be7e809a7c4a9df2b64b1fc5d6e939c0c5b9f448.tar
hurrycurry-be7e809a7c4a9df2b64b1fc5d6e939c0c5b9f448.tar.bz2
hurrycurry-be7e809a7c4a9df2b64b1fc5d6e939c0c5b9f448.tar.zst
smooth scrolling
Diffstat (limited to 'client')
-rw-r--r--client/menu/scroll_container_custom.gd8
1 files changed, 6 insertions, 2 deletions
diff --git a/client/menu/scroll_container_custom.gd b/client/menu/scroll_container_custom.gd
index 4908299e..b3ce4e46 100644
--- a/client/menu/scroll_container_custom.gd
+++ b/client/menu/scroll_container_custom.gd
@@ -19,11 +19,15 @@ class_name ScrollContainerCustom
# Adds support for scrolling with joypad and touch
const SCROLL_SPEED := 1000.
+var velocity := 0.
func _process(delta):
+ velocity = G.interpolate(velocity, 0., delta * 5.)
+ velocity = 0 if abs(velocity) < .001 else velocity
if Input.get_axis("scroll_up", "scroll_down") != 0.:
- set_deferred("scroll_vertical", scroll_vertical + Input.get_axis("scroll_up", "scroll_down") * delta * SCROLL_SPEED)
+ velocity = Input.get_axis("scroll_up", "scroll_down")
+ set_deferred("scroll_vertical", scroll_vertical + velocity * delta * SCROLL_SPEED)
func _input(event):
if event is InputEventScreenDrag:
- set_deferred("scroll_vertical", scroll_vertical - event.relative.y)
+ velocity = -(scroll_vertical - (scroll_vertical - event.relative.y)) * .1