mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Fix unnecessary recompose when calling LazyListState.isScrolledToEnd (#7598)
This commit is contained in:
parent
bc1f6ba517
commit
2e15be59af
1 changed files with 9 additions and 1 deletions
|
@ -8,7 +8,15 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
|
|
||||||
fun LazyListState.isScrolledToEnd() = layoutInfo.visibleItemsInfo.lastOrNull()?.index == layoutInfo.totalItemsCount - 1
|
@Composable
|
||||||
|
fun LazyListState.isScrolledToEnd(): Boolean {
|
||||||
|
return remember {
|
||||||
|
derivedStateOf {
|
||||||
|
val lastItem = layoutInfo.visibleItemsInfo.lastOrNull()
|
||||||
|
lastItem == null || lastItem.size + lastItem.offset <= layoutInfo.viewportEndOffset
|
||||||
|
}
|
||||||
|
}.value
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LazyListState.isScrollingUp(): Boolean {
|
fun LazyListState.isScrollingUp(): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue