-
Notifications
You must be signed in to change notification settings - Fork 554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: provide a HanziWriter.cancelAnimation()
to stop correctly al…
#44
Conversation
cf2ccdf
to
ec9b89a
Compare
Ack, cancelAnimation is another regression. I really need to add a lot more test coverage to prevent this from happening. Previously calling The way animations are handled right now is a mess that needs to be refactored. I think you've hit on the problem which is to be able to have some animations that can happen in parallel, while others need to take priority immediately. We also need to make sure that whenever we call a method we force the writer into a correct state no matter what animations are in progress. I think this PR is on the right track, but I want to take some time to rethink the animation model before merging this PR. |
I totally understand the need of tests and the time to think about what to do about this PR. If this makes any sense, and is of any help, in this PR, I had to use a common promise (HanziWrite._withDataPromise) as the common communication queue for all animation to double check that a stop was requested. This has allowed me to reach my goal (removing all lags and rogue animation) in a down to the ground and timely manner while not having to go through all your code (especially I'm thus not defending this structure, and of course if all animation are not stacked in various promises and chains, and they do their own checks would definitively be much better. If you need any help, I might have some times to put in that, though I completely understand also that you'll probably want to solve this yourself and it might be difficult to have someone helping you at this stage. |
…l animations. For several reason, animation where hard to stop: - no general ``HanziWriter.cancelAnimation()`` was provided, this is fixed, and the cancellation process is a complex one due to the many queues and hidden callbacks hanging after promises. - timeout function where used here and there in animation chains and would not check if the animation was canceled, inducing delays as they would not quit before completion. - the looping mechanism did not check for animation stop neither. The ``timeout`` function was expanded to allow any number of predicates to be checked every 5ms for early cancellation of the timeout.
ec9b89a
to
b98948f
Compare
I've tried the latest master (d30aa79) to see if I could avoid using this current PR. This is not yet the case: I don't know where to hook my event to be sure to be after the the ending of all animation. for instance, I call I've sent an updated code for this PR, I'm afraid I had to remove the part that forced a second I would be very happy not to need this PR to have clean cut-off of animations, so any other solution will be welcomed !. You may also have some other suggestion on the client code side that I'm ready to try also. |
Do |
I use If |
oops sorry I meant to say |
That's a wonderful idea. I would be for a simplification of the API on this side. all |
Closing this for now as most of these issues should have been fixed by now. As of #75, |
…l animations.
For several reason, animation where hard to stop:
HanziWriter.cancelAnimation()
was provided, this isfixed, and the cancellation process is a complex one due to the many
queues and hidden callbacks hanging after promises.
and would not check if the animation was canceled, inducing delays
as they would not quit before completion.
The
timeout
function was expanded to allow any number of predicatesto be checked every 5ms for early cancellation of the timeout.
cancelAnimation()
will also return a promise and ensure that the animation arestopped whenever the promise is resolved.