What is the best way to find out if a composable i...
# compose
s
What is the best way to find out if a composable is visible on screen? Im familiar with getting window rect / running intersection logic for a view, checking View.visible, etc. Is there a different way in compose?
3
d
I think I found a kind of a solution to this. I noticed that a composable does not have a height until it is visible on the screen, like this:
Copy code
.onGloballyPositioned {
    isVisibleOnScreen = it.boundsInRoot().height > 0f
}
where
isVisibleOnScreen
is a remembered mutable state. Hope it helps!