mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-07-13 13:41:23 +08:00
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:
@ -92,6 +92,7 @@ abstract class RiveRenderBox extends RenderBox {
|
|||||||
void _frameCallback(Duration duration) {
|
void _frameCallback(Duration duration) {
|
||||||
_elapsedSeconds = _stopwatch.elapsedTicks / _stopwatch.frequency;
|
_elapsedSeconds = _stopwatch.elapsedTicks / _stopwatch.frequency;
|
||||||
_stopwatch.reset();
|
_stopwatch.reset();
|
||||||
|
_stopwatch.start();
|
||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +110,8 @@ abstract class RiveRenderBox extends RenderBox {
|
|||||||
_frameCallbackId = null;
|
_frameCallbackId = null;
|
||||||
if (advance(_elapsedSeconds)) {
|
if (advance(_elapsedSeconds)) {
|
||||||
scheduleRepaint();
|
scheduleRepaint();
|
||||||
|
} else {
|
||||||
|
_stopwatch.stop();
|
||||||
}
|
}
|
||||||
_elapsedSeconds = 0;
|
_elapsedSeconds = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user