https://kotlinlang.org logo
Title
t

theapache64

01/19/2022, 10:57 AM
Hi there. I am trying to build an impression tracking SDK. To check if the
Composable
in the viewport, I am using a custom modifier with
onGloballyPositioned
method. Inside the lambda, am comparing the
x and y
cords of the
Composable
and compare it with window height/width. It works, but am wondering if there’s any better method/approach? 🙂
c

cb

01/19/2022, 11:29 AM
onGloballyPositioned
should generally be avoided (as much as possible) as it will be called a lot. It's kinda similar to
ViewTreeObserver.OnGlobalLayoutListener
which is invoked when any layout has happened. Feels like this would be better implemented as a
onPositionChanged
modifier, analogous to
Modifier.onSizeChanged
. That doesn't exist though.
t

theapache64

01/19/2022, 11:31 AM
@cb Okay. Do we have a ticket for this? or do I need to create one?
c

cb

01/19/2022, 11:32 AM
I don't have one 😄
t

theapache64

01/19/2022, 11:32 AM
Ohh.. i forgot 🤦‍♂️ ur not in the team anymore. @Leland Richardson [G] any idea?
😅 1
c

cb

01/19/2022, 11:42 AM
Just raise a FR? This is probably a better question for @George Mount
t

theapache64

01/19/2022, 12:10 PM