i have a LazyColumn with a VerticalScrollbar. how ...
# compose-desktop
z
i have a LazyColumn with a VerticalScrollbar. how can i know if the vertical scrollbar is at the bottom position? so that in my chat messages view it will only scoll to bottom on new incoming message when it was at the bottom. but when the user scrolls somewhere it should not automatically scroll to bottom on a new message incoming
s
LazyListState
has a
canScrollForward
property that you can check. And scrolling on new messages can be achieved by an
LaunchEffect
.
thank you color 1
z
is there a minial example. for some reason that property seems randomly true/false even when the scrollbar is in the same positon
also the scrollbar always scrolls down. maybe i am doing something wrong with my items data
s
What is your condition for the launch effect?
z
Copy code
LaunchedEffect(messages.last().msgDatabaseId)
s
Looks plausible
For the randomly true/false I would suggest that you create a small reproducer app and report an issue.
This is the template I usually use for that: https://github.com/JetBrains/compose-multiplatform-template