Replies: 2 comments
-
What you ask is unfortunately not yet implemented. I think you don't need to have a fixed height using your trick. import { Button, HorizontalBox } from "std-widgets.slint";
export component Demo {
width: 150px;
height: 300px;
property <[{o: float, v: bool, c: color}]> props: [{ c: rgb(255,0,0) }, { c: rgb(0,255,0) }, { c: rgb(0,0,255) }, { c: rgb(0,255,255) }, { c: rgb(255,0,255) }, { c: rgb(255,255,0) }];
property <int> c: 0;
VerticalLayout {
Rectangle {
border-width: 2px;
border-color: red;
VerticalLayout {
alignment: start;
Button {
text: "add";
clicked => {
props[c].o = 1;
props[c].v = true;
c = c + 1;
}
}
for x[i] in props: Rectangle {
height: x.v ? layout.preferred-height : 0px;
opacity: x.o;
background: x.c;
animate opacity { duration: 500ms; }
animate height { duration: 500ms; }
layout := HorizontalBox {
Text {
text: i + "+"+ parent.opacity;
}
}
TouchArea {
clicked => {
x.o = 0;
x.v = false;
}
}
}
}
}
Rectangle { }
}
} |
Beta Was this translation helpful? Give feedback.
-
It sounds like what you are looking for is appear and disappear animations which are not yet supported. I managed to make something work but its a bit hacky and requires extra boilerplatete. This discussion #4932 has some more info. You could also look at my sample repo linked in that discussion or the final form as implemented in Tomotroid. I'm on mobile so I don't have time to try and type up a more detailed answer, but hopefully that points you in the right direction. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For example, a model holds a list of cards. Add one card and then animate its opacity. Using VecModel::push with opacity property and then updating it with Model::set_row_data isn't the proper way. It seems it is possible to simulate this by preloading a card count with default values as in the example below. Click "click" a few times and then click each of the cards to see the intended effect. Unfortunately, with this approach height of each element is fixed.
Beta Was this translation helpful? Give feedback.
All reactions