mattinger
10/25/2021, 2:42 PMmattinger
10/25/2021, 2:43 PM@Composable
private fun NumberCard(modifier: Modifier = Modifier, index: Int, onImpression: (Int) -> Unit) {
LaunchedSideEffect("NumberCard $index") {
onImpression(index)
}
Card(modifier = Modifier.fillMaxWidth()) {
Text(text=index.toString())
}
}
mattinger
10/25/2021, 2:47 PMAdam Powell
10/25/2021, 3:19 PMsnapshotFlow
to get a flow from any snapshot-observable object, fwiwAdam Powell
10/25/2021, 3:19 PMAdam Powell
10/25/2021, 3:22 PMAdam Powell
10/25/2021, 3:23 PMmattinger
10/25/2021, 4:40 PMmattinger
10/25/2021, 4:40 PMAdam Powell
10/25/2021, 7:06 PMModifier.onGloballyPositioned {}
will give you access to the size and position when it changes, even within other containers. Intersect that against your viewport and you have the data you needAdam Powell
10/25/2021, 7:06 PMAdam Powell
10/25/2021, 7:07 PMeneim
11/29/2021, 1:17 PMonGloballyPositioned
is not called anymore. I have no idea how to record that event (it is easier when the element is scroll into screen, since the callback is called). Can you suggest how can I observe this event?Adam Powell
11/29/2021, 2:17 PMeneim
12/10/2021, 12:51 PM