Skip to content

Animating opacity on component with zero size makes it invisible during animation #11431

@hulthe

Description

@hulthe

Bug Description

Trying to animate opacity on an object with zero size (height: 0px) breaks the opacity animation.

In the example below, the accordion children are expected to fade in while expanding. Instead they are invisible until the animation finishes.

Trying to animate the opacity from a non-zero value (e.g. 0.99 -> 1.0) also makes the component invisible.

This is reproducible in SlintPad.

Reproducible Code (if applicable)

import { AboutSlint, Button } from "std-widgets.slint";

component Accordion inherits VerticalLayout {
    property <bool> expanded;
    
    width: 90%;

    Button {
        text: "Accordion";
        clicked => { expanded = !expanded; }
        height: 80px;
    }

    Rectangle {
        clip: true;
        opacity: 0;  // any value below 1 triggers the behavior
        height: 0px; // 1px works as expected

        states [
            expanded when expanded: {
                height: self.preferred-height;
                opacity: 1;
        
                in-out {
                    animate height, opacity {
                        duration: 0.5s;
                    }
                }
            }
        ]

        @children
    }
}

export component Demo {
    width: 400px;
    height: 520px;
    VerticalLayout {
        alignment: start;
        Accordion {
            Accordion {
                Accordion {
                    AboutSlint {}
                }
            }
        }
    }
}

Environment Details

  • Slint Version: 1.16.0
  • Platform/OS: All
  • Programming Language: N/A
  • Backend/Renderer: femtovg

Product Impact

Not critical, just inconvenient to debug, and it means our animations will look worse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:renderer-femtovgFemtovg renderer (mS)need triagingIssue that the owner of the area still need to triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions