fix(anim): compensate over time (#6989)

This commit is contained in:
Gabor Kiss-Vamosi
2024-10-12 03:11:07 +02:00
committed by GitHub
parent 52665bf303
commit 08d2c34d6c

View File

@@ -533,8 +533,10 @@ static void anim_timer(lv_timer_t * param)
}
if(a->act_time >= 0) {
int32_t act_time_original = a->act_time; /*The unclipped version is used later to correctly repeat the animation*/
if(a->act_time > a->duration) a->act_time = a->duration;
int32_t act_time_before_exec = a->act_time;
int32_t new_value;
new_value = a->path_cb(a);
@@ -545,6 +547,10 @@ static void anim_timer(lv_timer_t * param)
if(!state.anim_list_changed && a->custom_exec_cb) a->custom_exec_cb(a, new_value);
}
/*Restore the original time to see is there is over time.
*Restore only if it wasn't changed in the `exec_cb` for some special reasons.*/
if(a->act_time == act_time_before_exec) a->act_time = act_time_original;
/*If the time is elapsed the animation is ready*/
if(!state.anim_list_changed && a->act_time >= a->duration) {
anim_completed_handler(a);
@@ -592,7 +598,10 @@ static void anim_completed_handler(lv_anim_t * a)
}
/*If the animation is not deleted then restart it*/
else {
a->act_time = -(int32_t)(a->repeat_delay); /*Restart the animation*/
/*Restart the animation. If the time is over a little compensate it.*/
int32_t over_time = 0;
if(a->act_time > a->duration) over_time = a->act_time - a->duration;
a->act_time = over_time - (int32_t)(a->repeat_delay);
/*Swap the start and end values in play back mode*/
if(a->playback_duration != 0) {
/*If now turning back use the 'playback_pause*/