stop the stopwatch if we are no longer advancing the animations, so they do not jump to an unintended timepoint when restarted

This commit is contained in:
Maxwell Talbot
2020-09-30 09:42:17 +01:00
parent 5d6a46837e
commit 951a4251f2

View File

@ -92,6 +92,7 @@ abstract class RiveRenderBox extends RenderBox {
void _frameCallback(Duration duration) {
_elapsedSeconds = _stopwatch.elapsedTicks / _stopwatch.frequency;
_stopwatch.reset();
_stopwatch.start();
markNeedsPaint();
}
@ -109,6 +110,8 @@ abstract class RiveRenderBox extends RenderBox {
_frameCallbackId = null;
if (advance(_elapsedSeconds)) {
scheduleRepaint();
} else {
_stopwatch.stop();
}
_elapsedSeconds = 0;