Hello 👋 Is there a way to intercept touch events such as
ACTION_DOWN
and
ACTION_UP
but still allow a LazyColumn to have
ACTION_MOVE
for scroll? My use case is: I want to allow a full screen list to scroll, but I want to do something when a finger is lifted up such as snap the list to a specific position
z
Zach Klippenstein (he/him) [MOD]
09/27/2021, 7:32 PM
I believe the nested scrolling API gives you a hook for when scrolling transitions to fling
c
Chris Johnson
09/27/2021, 7:36 PM
Hmn. Yeah there is onPre and onPost fling but really I only care about
ACTION_UP
. The user could be slowly scrolling my content and when they lift their finger up I want to snap the list into place. For context, I'm basically trying to re-create the default behavior we got from the MaterialCollapsingToolbar. I have a working implementation listening for when the scrollState's
isScrollInProgress
and that works to check when they've stopped scrolling, but that also causes a LOT of recompositions in a very large complex composable. So I'm trying to avoid that as it causes noticeable lag.
z
Zach Klippenstein (he/him) [MOD]
09/27/2021, 7:38 PM
You can use
derivedStateOf
to avoid recomposing on every
isScrollInProgress
update.
c
Chris Johnson
09/27/2021, 7:43 PM
Ah I didn't even think of that state. You're a life saver man. Thanks!