Shakil Karim
02/21/2021, 10:10 AMLazyColumn(
state = scrollState,
modifier = Modifier.fillMaxSize()
) {
item {
LogCompositions("CompetitionDetailsScreenNew header")
//Some item
}
}
Andrey Kulikov
02/21/2021, 2:51 PMShakil Karim
02/21/2021, 3:44 PMAndrey Kulikov
02/21/2021, 6:06 PMcollapseFraction
calculation right where it is used, inside graphicsLayer { .. here .. }
Andrey Kulikov
02/21/2021, 6:07 PMscrollState.firstVisibleItemScrollOffset
update (every scroll) instead of doing recomposition we will only need to update a params on graphics layer, which is very cheapAndrey Kulikov
02/21/2021, 6:10 PMval collapseFraction =
(scrollState.firstVisibleItemScrollOffset / collapseRange).coerceIn(0f, 1f)
you do:
val collapseFraction = remember(collapseRange) {
derivedStateOf { (scrollState.firstVisibleItemScrollOffset / collapseRange).coerceIn(0f, 1f) }
}
and now when you use collapseFraction.value
this value is only recomposed when the resulting float fraction changes.Shakil Karim
02/22/2021, 6:20 AMAndrey Kulikov
02/22/2021, 12:18 PM