Nikhil

    Nikhil

    1 year ago
    How can I get the center of any composable element? I was trying using
    onGloballyPositioned{..}
    (I also have some other code and I want to avoid adding it this modifier since it’s called a lot.) Is there any method/modifier where I can get any alternative of Rect/
    bounds
    ?
    Doris Liu

    Doris Liu

    1 year ago
    What do you need the Rect/Bounds for? Maybe there are other ways to achieve what you are trying to do
    Nikhil

    Nikhil

    1 year ago
    I need center position/coordinates of the composable element. How can I get that?
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Why do you need them?
    Nikhil

    Nikhil

    1 year ago
    I’m trying to draw some animation from the center of the composable element.
    w

    Waqas Tahir

    1 year ago
    this can't be done without size which you would get from onSizeChanged Modifier and then you can calculate center from onGloballyPositioned coordinates , and everytime onSizeChanged is called recalculate the center !
    Nikhil

    Nikhil

    1 year ago
    Right. That’s what I’m trying right now with
    onGloballyPositioned{..}
    . I was asking if there’s any other way.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    If your animation is just drawing, you can use a drawBehind modifier (or other draw modifier) and then you have access to the size from the DrawScope
    Nikhil

    Nikhil

    1 year ago
    Yeah, Thanks.