https://kotlinlang.org logo
#compose
Title
# compose
k

Kulwinder Singh

12/06/2023, 6:18 AM
Is there Event about when composable is visible on screen or not on-screen, i have scenario in which i have to perform certain action only when Composable is *on-screen*(it is inside scrollable Column)
t

Timo Drick

12/06/2023, 9:46 AM
There is this DisposableEffect which you can use to track the livecycle of the composable. For LazyLists this matches also more or less visibility. But for scrollable column it does not match. As far as i know there is no event for visibility.
s

Shahzad Ansari

12/06/2023, 12:51 PM
LazyListState
provides
firstVisibleItemIndex
property which you can use to detect if certain item is visible or not based on their index.
z

Zach Klippenstein (he/him) [MOD]

12/07/2023, 3:40 PM
onGloballyPositioned + asking the layout for trimmed bounds in window should do it
2 Views