handle ui resize in carousel

This commit is contained in:
Nordup 2025-08-11 00:52:18 +07:00
parent 86ad20e452
commit 9e46290c36

View file

@ -13,6 +13,7 @@ func _ready() -> void:
setup_boards()
assert(boards.size() > 0, "Carousel must have at least one board")
ui_events.ui_size_changed.connect(on_ui_size_changed)
move_line(0)
@ -24,6 +25,13 @@ func setup_boards() -> void:
boards[i].request_focus.connect(move_line.bind(i))
func on_ui_size_changed(ui_size: Vector2) -> void:
var screen_center = ui_size.y / 2
line.position.y = screen_center - line.size.y / 2
move_line(focused_page)
func move_line(board_index: int) -> void:
var board = boards[board_index]
focused_page = board_index