I have a lazy list that I am animating scroll to Item when clicking on a button.
onClick = {
scope.launch {
lazyListState.animateScrollToItem(selectedIndex)
}
}
Why is it that the animateScrollToItem is SO fast? Can I slow it down a little? I am not seeing anywhere I can add a animationSpec, and with animateScrollBy() I would need to pass in a float rather than an index - which I do not want.
That's the only possible way for now. animateScrollBy() is not that bad by the way, all you need is to know the size of the lazy container item.
val itemSize = 50.dp
val density = LocalDensity.current
val itemSizePx = with(density) { itemSize.toPx() }
val itemsScrollCount = 150
coroutineScope.launch {
lazyListState.animateScrollBy(
value = itemSizePx * itemsScrollCount
animationSpec = tween(durationMillis = 5000)
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With