fjvallarino/monomer

Animation Widget raises onFinished event when it is no longer relevant

Closed this issue · 4 comments

If you send AnimationStart message to an animation widget (e. g. animSlideIn, animFadeIn) before its animation ends, it raises onFinished event before finishing animation. Same situation if you send AnimationStop message and then AnimationStart message before duration of previous animation exceeds.

Here I modified dev-test-app to demonstrate this behavior and introduced possible fix by adding a start timestamp parameter to the AnimationFinished message. In this case if animation widget receives AnimationFinished message, it not only checks if animation is running, but also compares message's timestamp parameter with the start timestamp of the current state.

I tested it only on Windows 10, but I think it should work everywhere. Should I create a pull request?

I recorded video to demonstrate animation behavior without and with my modifications:

monomer-animation-bug.mp4

Hi @Deltaspace0!

I'm still thinking about this one. The AnimationMessage is being sent because the listener may be interested in knowing that the animation stopped somehow. But you raise a valid point, since it didn't really finish and the listener does not now that.

I'm currently debating about adding a new event (AnimationInterrupted) or just not raising the event.

@Deltaspace0 sorry, I didn't realize there was a link to the fix you proposed, and I also misunderstood what the issue was.

Your fix looks great! Please submit a PR. Thanks!

The fix you provided has just been merged into main.

I'll close the issue now. Thanks!