compose-collapsing-toolbar
compose-collapsing-toolbar copied to clipboard
Not collapsing when using LazyListState.animateScrollToItem
Hi
when running this code, where state is the LazyListState of the LazyColumn which is the body, the CollapsingToolbarScaffold doesn't collapse and the LazyColumn scrolls behind it.
Thanks for the help
coroutineScope.launch {
delay(500)
state.animateScrollToItem(issue.comments.size - 1)
}
I am looking at the implementation of LazyList, though I'm not sure what is going on exactly, it seems that animateScrollToItem()
does not dispatch nested scroll. If this is true, then there is barely nothing my code can do to fix it for now. I will try to investigate what is going on and notify you when I find something :)
Thanks @onebone !
@antoine-purnelle-lb wanna file a bug report with jetpack compose?
Any update on this issue? acing the same issue or any work around
Any update on this issue? acing the same issue or any work around
I think we should manually expand or collapse the toolbar. Given animateScrollToItem()
and expand()
/collapse()
is a suspending function, it should be easy to do it.
@onebone I have tried to collapse() manually but it does not work. I have the following code
val rememberCollapsingToolbarScaffoldState = rememberCollapsingToolbarScaffoldState()
in suspend block call following
rememberCollapsingToolbarScaffoldState.toolbarState.collapse(100)
any thing wrong with it? thanks in advance
@aniluMango Sorry for the late response, I see no problems in your given code. Maybe there some are reason if it does not work? The following is my tested code, which collapses the toolbar and scrolls a lazy list to index 5.
Button(
onClick = {
scope.launch {
state.toolbarState.collapse()
listState.animateScrollToItem(5)
}
}
) {
Text(text = "Floating Button!")
}
Is there no notify
or invalidate
method we could use on the toolbarState so that it calculates itself if it has to collapse or not?