Only scrolls to the top if not at the top

This commit is contained in:
Vitor Pamplona
2023-05-25 18:30:15 -04:00
parent 4f2c78e73a
commit 9f394900a7
2 changed files with 6 additions and 2 deletions
@@ -104,7 +104,9 @@ private fun FeedLoaded(
if (scrollToTop) {
LaunchedEffect(Unit) {
listState.scrollToItem(index = 0)
if (listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > 0) {
listState.scrollToItem(index = 0)
}
}
}
@@ -119,7 +119,9 @@ private fun FeedLoaded(
if (scrollToTop) {
LaunchedEffect(Unit) {
listState.scrollToItem(index = 0)
if (listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > 0) {
listState.scrollToItem(index = 0)
}
}
}