https://kotlinlang.org logo
#compose
Title
# compose
d

dimsuz

06/10/2021, 12:37 PM
I have Swipeable switching between 3 states. Inside it there's a LazyColumn. What is the best way to initiate scroll to item 3 in that column once swipeable settles on a certain state? I imagine running LaunchedEffect, but at what point? Should I somehow store previousSwipeableState and check it against a new state and if they differ — fire away? But how to store previous state?
m

matvei

06/10/2021, 12:58 PM
LaunchedEffect
has a
key
parameter, when the key changes -- effect will restart, so smth like thinks might work:
Copy code
LaunchedEffect(bottomSheet.currentValue) {
    if (bottomSheet.currentValue == certainValue) {
        lazyState.scrollToItem(3)
    }
}
d

dimsuz

06/10/2021, 1:46 PM
great, thank you!