Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Animation

    Smoothly animates the scale and opacity of its child. When the parameters change, a 300 ms animation is applied automatically.

    Type: single-child

    Animation @opacity:0.5
      Text "Semi-transparent"

    Parameters

    Parameter Type Description
    scale double Scale factor (animated with AnimatedScale )
    opacity double Opacity from 0.0 to 1.0 (animated with AnimatedOpacity )
    duration duration Transition duration, 300ms by default. When animations are turned off in the system, the transition takes one frame
    Parameters are usually declared reactive ( @ ) so that they animate when their values change.

    Examples

    Animation on hover

    Hovered writes to a variable whether the pointer is over its child, and Animation smoothly brings the value to the new one:

    Hovered hovered:@over
      Animation opacity:{over ? 1.0 : 0.4} duration:200ms
        Text "Hover over me"

    Scaling

    Hovered hovered:@over
      Animation scale:{over ? 1.1 : 1.0}
        SizedBox width:200 height:200
          ColoredBox color:#6C63FF

    Combined animation

    Hovered hovered:@over
      Animation scale:{over ? 1.05 : 1.0} opacity:{over ? 1.0 : 0.5}
        ColoredBox color:#6C63FF
          Padding
            #padding all 20
            Text "Card"

    See also

    • Button — a source of events to drive the animation