is `onGloballyPositioned` supposed to be called more than once after a layout? Or is supposed to onl...
b
is
onGloballyPositioned
supposed to be called more than once after a layout? Or is supposed to only be called once it’s positioned? I ask because I have a composable that is constantly calling
onGloballyPositioned
despite not moving or recomposing (at least to my knowledge).
l
expect
onGloballyPositioned
to get called a lot
what is it that you are using it for?
b
So what I’m trying to do is determine the location of my composable on the screen because when it’s in a certain area I want ExoPlayer to start auto playing a video
I can get it to work no problem, but obviously it’s a bit chatty
l
yeah. you want to make sure the work you’re doing in that function is pretty minimal most of the time (until some condition is met for instance)
there are cheaper modifiers like
onSizeChanged
but it doesn’t sound like your use case would be satisfied for that, so onGloballyPositioned is probably right
735 Views