johnny-five
johnny-five copied to clipboard
Calling animation.next inside onloop callback is not working.
@dtex @rwaldron Hello guys, hope you're well.
First issue
When using the Animation API there is no way out from onloop
callback using animation.next
The next
function is watch for isRunning === true
and prevent going to next.
https://github.com/rwaldron/johnny-five/blob/094bf6cceb8b9ec424306da8e98308ebd6fa2252/lib/animation.js#L85-L91
If we call pause
right before, this is not working too because it doesn't turn running
false.
https://github.com/rwaldron/johnny-five/blob/094bf6cceb8b9ec424306da8e98308ebd6fa2252/lib/animation.js#L125-L138
if we call stop
we clear the stack because this
https://github.com/rwaldron/johnny-five/blob/094bf6cceb8b9ec424306da8e98308ebd6fa2252/lib/animation.js#L150
So we can't go to the next animation.
Only solution is to call stop
and trigger a new animation from within the callback.
Second issue
oncomplete
callback is not called for current animation when using stop()
. But it only call onStop
Maybe we could think about something else ?