Thread
#compose
    Alexander Sitnikov

    Alexander Sitnikov

    1 year ago
    I want to create a card flip animation (

    like this

    ), and the only way I found is using
    Modifier.drawLayer(rotationY = someValue)
    , but this animation looks too distorted (

    like this

    ). View has
    setCameraDistance()
    method, and RenderNode has this method too, but Compose doesn't use any of them. It seems to me that
    rotationY
    parameter is kinda useless without camera distance. Is there any way to create this card flip animation other than
    drawLayer
    ? Or maybe there's plans to include support for camera distance in future versions of Compose?
    l

    Leland Richardson [G]

    1 year ago
    cc @Nader Jawad
    r

    romainguy

    1 year ago
    That’s because Skia doesn’t do perspective correc transformations
    Camera distance would help but only to a certain point
    Still, seems worth adding
    (or picking a better default)
    Halil Ozercan

    Halil Ozercan

    1 year ago
    @romainguy
    Camera distance would help but only to a certain point
    I was also going to say the same thing. Maybe scaling the view while also doing the animation help but not sure about that either
    r

    romainguy

    1 year ago
    No, the problem is more fundamental
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    Halil Ozercan

    Halil Ozercan

    1 year ago
    yes, now thinking about scaling, the far end would look very weird
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    looks like this:

    https://github.com/zach-klippenstein/compose-backstack/raw/main/.images/inspector.gif

    r

    romainguy

    1 year ago
    The text looks very very wrong in your example 😛
    These “3D” rotations are just shears/skews, which is why it looks bad on text or images
    Alexander Sitnikov

    Alexander Sitnikov

    1 year ago
    should I file an issue then?
    r

    romainguy

    1 year ago
    Yes please
    Sergey Y.

    Sergey Y.

    1 year ago
    @Alexander Sitnikov But keep in mind that changes to the Skia runtime can only ship with a newer version of Android. Compose does not ship with its own version of Skia. 🙄
    Alexander Sitnikov

    Alexander Sitnikov

    1 year ago
    r

    romainguy

    1 year ago
    We’re not talking about introducing true 3D transforms here, just the camera distance 🙂
    This doesn’t require touching Skia
    Nader Jawad

    Nader Jawad

    1 year ago
    camera distance has been added to the layer APIs in compose and should be available in a future release of compose
    r

    romainguy

    1 year ago
    Awesome, thanks Nader!