diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index 5595ef68..35357778 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -279,6 +279,12 @@ open class Carousel: View { updatePaginationControls() addCarouselSlots() + + // If selectedIndex is received, the carousel should update its position. + if let selectedIndex { + let totalPos = totalPositions() + carouselScrollBar.position = selectedIndex >= totalPos ? totalPos : selectedIndex+1 + } } /// Resets to default settings. @@ -300,6 +306,12 @@ open class Carousel: View { nextButton.onClick = { _ in self.nextButtonClick() } previousButton.onClick = { _ in self.previousButtonClick() } + /// Will be called when the scrubber position changes. + carouselScrollBar.onScrubberDrag = { [weak self] scrubberId in + guard let self else { return } + updateScrollPosition(position: scrubberId, callbackText:"onThumbPositionChange") + } + /// Will be called when the scrollbar thumb move forward. carouselScrollBar.onMoveForward = { [weak self] scrubberId in guard let self else { return }