I have a `LazyColumn` and I need to do certain act...
# compose
d
I have a
LazyColumn
and I need to do certain actions based if user has scrolled up or down for a certain threshold. What are my best options here? • Use
snapshotFlow
to watch
LazyColumnState
changes, collect delta, act accordingly? • I've also found
pointerInput
+
detectDragGesture
, will it work with
LazyColumn
, should I use it? • Something else?
c
What kind of actions? If the actions are async and will trigger composition (i.e. to show some UI) or should be cancellable from scrolling then you probably want to use
LaunchedEffect()
, possibly with
derivedStateOf()
to map to the desired state. If the actions are completely disconnected from the UI (i.e. analytics),
snapshotFlow()
is more applicable.
d
I plan to fade in/out a certain button (or maybe use an
offset
modifier on it), so I guess this will trigger composition. I'll read up on
derivedStateOf()
then 👍
Another reason I've asked is I suspected that there might be some solution to detect "user has scrolled up/down for X pixels" events, so I need not invent my own :)