Hello :wave: Is there a way to intercept touch eve...
# compose
c
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
I believe the nested scrolling API gives you a hook for when scrolling transitions to fling
c
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
You can use
derivedStateOf
to avoid recomposing on every
isScrollInProgress
update.
c
Ah I didn't even think of that state. You're a life saver man. Thanks!
Works as intended and is way smoother
👍🏻 1