@tool
class_name IndexCarousel extends Carousel

signal index_changed(index: int)

@export var with_drag: bool = false
@export var with_clamp: bool = false

var current_index: int = 0

func _ready() -> void:
    current_index = get_carousel_index(with_drag, with_clamp)

func _on_progress(_scroll: int) -> void:
    var next_index = get_carousel_index(with_drag, with_clamp)
    if current_index != next_index:
        current_index = next_index
        index_changed.emit(next_index)
