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,9 +104,11 @@ private fun FeedLoaded(
if (scrollToTop) { if (scrollToTop) {
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
if (listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > 0) {
listState.scrollToItem(index = 0) listState.scrollToItem(index = 0)
} }
} }
}
LazyColumn( LazyColumn(
contentPadding = PaddingValues( contentPadding = PaddingValues(
@@ -119,9 +119,11 @@ private fun FeedLoaded(
if (scrollToTop) { if (scrollToTop) {
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
if (listState.firstVisibleItemIndex > 0 || listState.firstVisibleItemScrollOffset > 0) {
listState.scrollToItem(index = 0) listState.scrollToItem(index = 0)
} }
} }
}
val baseModifier = remember { val baseModifier = remember {
Modifier Modifier