hi, is there a way to get data from onGloballyPosi...
# compose
n
hi, is there a way to get data from onGloballyPositioned modifier only once? I have an Image composable (which is zoomable) and I need to get its initial width and height, but I don't want to update it when I zoom. Here's how I'm getting image's width and height on the device screen right now
Copy code
.onGloballyPositioned { layoutCoordinates ->
    imageHeight =
        with(localDensity) { layoutCoordinates.size.height.toDp() }
    imageWidth =
        with(localDensity) { layoutCoordinates.size.width.toDp() }
}
And I'm using them in an offset calculation like this
Copy code
val offsetTop = windowInfo.screenHeight.minus(imageHeight).div(4)
val offsetStart = windowInfo.screenWidth.minus(imageWidth).div(4)
1
t
I think you wrap it in a BoxWithConstraints and it gives you width and height
n
I'll give it a try, thank you very much!
@Tgo1014 maybe I'm doing something wrong, but box's max height param is not giving me image's height, even though I'm using "wrapContentSize" modifier
max height is returning screen's height in dp