Closed syf20020816 closed 1 year ago
That is due to the rotation animating from the current value to the newly set value. So the first time round you rotate from 0 to 360°. Then you stop at some angle. Then you start again, rotating from whatever that angle was when you stopped to the new target value.
MAybe you can try someting like this
I'll edit your report a bit and leave it open as we should have a way to reset animations more cleanly.
PS: Thank you for the excellent bug report!
Thank you for providing the case, but after my inspection, it seems that the problem lies in the issue of loop animation failure when using the visible
property to hide the component
Thank you for double checking. Looks like the visibilit change indeed has some unintended side effect ion the animation.
The animate rotation-angle { ... }
means it animates from the current position to the new position in that amount of time.
So if you set rotation-angle = xyz;
it will animate from the current value to xyz
. But if you call it twice, the current value depends on the animation, so the behavior is correct.
The truth is that iteration-count is not a great way to get continuously rotating animation. For this kind of usecase, you are better off with animation-tick.
For example: Link
rotation-angle: !animating ? 0deg : 360deg * animation-tick()/loading_animation_duration;
(this doesn't have an easing curve, but you can get one with some math in the binding)
Root cause is that the animation gets stopped at some value between 0 and 360° and animates from that (random) value to 360°.
We should have a way to cleanly reset animations in use-cases like this one. -- @hunger
Original report follows:
My Goal
I want to write a loading component , when this component show the loading icon will rotate in an infinite loop
error video
The icon in the component can rotate normally during the first run, but after multiple runs, the animation shows an exception
https://github.com/slint-ui/slint/assets/92167095/ee874119-876b-4d22-a6f2-e4db73659e1a
Source Code Repo
loading.slint : https://github.com/syf20020816/SurrealismUI/tree/main/src/loading/loading.slint test : https://github.com/syf20020816/SurrealismUI/blob/main/tests/src/loading.slint
Code
test code