Several bugs when using calculated animate duration property
Bug Description
This is a bug based on duscussion #7973 .
When trying to get duration property of animate be calculated based on other properties I encountered several issues. At high level here, later are more specific examples:
- Crash of Slint LSP/Live-preview + slintpad becomes unfuncional
- Work or doesn't work depending on the property use
- Depending on added/removed element to a VerticalLayout the animation work/stop working
- Duration calculation when work, seems to end up not take the correct time as the calculation shows There are a few options there to uncomment:
animate y {
duration: 2s; //<- always work
//duration: list.height / 200px * 5s; // <- works on my local machine slint live preview, not on slintpad
// duration: list.preferred-height / 200px * 1s; // <- doesn't work anywhere
// duration: top-items.length * 1s; // <- crash the slint LSP/Live-preview, slintpad(stop working)
easing: ease-in-out;
}
The interesting thing is (list referred to below is is a VerticalLayout)
- The constant work.
- The duration based on list.height - work on my local slint-preview, but doesn't in slintpad.
- The duration based on list.preferred-height - doesn't work on neither slint-preview nor slintpad
- The duration base on a property which is an array of string, length: crashed my Lsp / Local SlintPreview, and also hangs SlintPad.
In Example 2 which is similar to previous one, I managed to get the preferred-height to influence by trial and error. However:
- To make it animate, I had to add a small rectangle there. without it, it jumps as if duration is zero.
- Any minor change to the rectangle height has large influence on the duration calculation even though the rectangle is very small compared to the preferred-height
- The duration time that takes place is very different from the calculation - I added the calculation information on top of the display so it can be seen. it should be 98 sec, while in practice it's only a few seconds.
Reproducible Code (if applicable)
Environment Details
- Slint Version: Reproduced on SlintPad
Product Impact
No response
Thanks for the bug report.
Animations are not initialized lazily currently. They are initialized when the component is initialized. At that time, it doesn't have a size yet (size=0) and that's why it's not working. Also the crash you get is because it tries to access a model that wasn't yet initialized to a proper model.
Thanks for the bug report.
Animations are not initialized lazily currently. They are initialized when the component is initialized. At that time, it doesn't have a size yet (size=0) and that's why it's not working. Also the crash you get is because it tries to access a model that wasn't yet initialized to a proper model.
I understand, thanks.
Is there a way to maybe do conditional animation? I need to animate y and sometimes I need it to be animated and sometimes not (after the control is created, depending on the action). Any way to achieve that? Maybe using states or some other way (couldn't make it work so far).
You can do conditional animations via states. In some cases you can achieve the same thing without them by having a variable for the duration of the normal animation. Just set the duration to 0 when you don't want the animation.
Home Automation Demo tries to change durations based on gpu availablity. But because of this issue, it doesn't work as expected.
https://github.com/slint-ui/slint/blob/master/demos/home-automation/ui/common.slint#L36
export global Animation {
out property <duration> full-screen-duration: AppState.graphics-accelerator-available ? 300ms : 0;
out property <duration> transition-duration: AppState.graphics-accelerator-available ? 500ms : 0;
}