I am using a `nestedScroll(...)` to create a coll...
# compose
a
I am using a
nestedScroll(...)
to create a collapsing toolbar (code in thread). However implementing it this way is disabling any flinging on the list. I am not sure why, because I am not consuming the Flings in my nested scroll, or do I? Will I have to reimplement flinging animations when using nested scrolling?
Copy code
modifier = Modifier
  .nestedScroll(
    connection = object : NestedScrollConnection {
      override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
        val scrollInDp = available.y / density

        if (scrollInDp > 0 && state.value != 0)
          return Offset.Zero

        val newHeight = (headerHeight + scrollInDp)
            .coerceIn(0f..maxHeaderHeight)

        val consumed = newHeight - headerHeight

        headerHeight = newHeight

        return Offset(0f, consumed * density)
      }
    },
  )
a
I don’t notice something wrong. This bug may affect your case: https://issuetracker.google.com/issues/179417109
a
Thanks for the heads up @Alex Gabor! I have asked the same question in that thread. Since this bug is quite old (in compose terms anyways) I am not sure if this would still be the case, but it looks like it's not fixed. At least reading from the issue type. So it might be that.
Actually the fling is only broken on the outer scroll container, the inner scroll container is still flinging. Would be nice though if flings transferred over from the inner scrolling child to the outer one
a
yes, the bug doesn’t affect flinging in child. The fling is sent up, the only problem now is that it sends wrong values.
a
This bug doesn't prevent the fling, it just results in wrong fling velocity. If your list is not flinging at all, it's probably not related to this bug.
l
Any new updates on the fling issue? I am also working on a collapsing toolbar and I am getting wrong velocity values while flinging.
a
You can star the issue to follow future updates.