From cd18aa57fa0c11bf455132d0c764d1340455eed1 Mon Sep 17 00:00:00 2001 From: tpart Date: Thu, 29 Aug 2024 15:28:04 +0200 Subject: Automatically scroll chat to bottom when opened --- client/menu/scroll_container_custom.gd | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'client/menu/scroll_container_custom.gd') diff --git a/client/menu/scroll_container_custom.gd b/client/menu/scroll_container_custom.gd index cc578bb1..a456f644 100644 --- a/client/menu/scroll_container_custom.gd +++ b/client/menu/scroll_container_custom.gd @@ -21,9 +21,18 @@ class_name ScrollContainerCustom const SCROLL_SPEED := 1000. var velocity := 0. +@export var auto_scroll_to_bottom := false + func _init(): follow_focus = true +func _ready(): + if auto_scroll_to_bottom: + call_deferred("scroll_to_bottom") + +func scroll_to_bottom(): + set_deferred("scroll_vertical", get_v_scroll_bar().max_value) + func _process(delta): velocity = G.interpolate(velocity, 0., delta * 5.) velocity = 0. if abs(velocity) < .001 else velocity -- cgit v1.2.3-70-g09d2