Digital ACT-191 ONEAPP-7013 story: updating carousel position if receives selectedIndex

This commit is contained in:
Vasavi Kanamarlapudi 2024-07-18 12:49:12 +05:30
parent 4ae07b6402
commit c2ec941a3c

View File

@ -279,6 +279,12 @@ open class Carousel: View {
updatePaginationControls() updatePaginationControls()
addCarouselSlots() 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. /// Resets to default settings.
@ -300,6 +306,12 @@ open class Carousel: View {
nextButton.onClick = { _ in self.nextButtonClick() } nextButton.onClick = { _ in self.nextButtonClick() }
previousButton.onClick = { _ in self.previousButtonClick() } 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. /// Will be called when the scrollbar thumb move forward.
carouselScrollBar.onMoveForward = { [weak self] scrubberId in carouselScrollBar.onMoveForward = { [weak self] scrubberId in
guard let self else { return } guard let self else { return }