rive-flutter icon indicating copy to clipboard operation
rive-flutter copied to clipboard

Rive animations do not respect TickerMode

Open goderbauer opened this issue 3 years ago • 1 comments

Description

TickerMode [1] is used in flutter to turn off animations for a subtree. However, it appears that rive is not respecting the setting.

[1] https://master-api.flutter.dev/flutter/widgets/TickerMode-class.html

Steps To Reproduce

Steps to reproduce the behavior:

  1. Wrap the simple animation of the example app with a TickerMode(enabled: false, child: ...):
      TickerMode( // new
        enabled: false, // new
        child: const Center(
          child: RiveAnimation.network(
            'https://cdn.rive.app/animations/vehicles.riv',
            fit: BoxFit.cover,
          ),
        ),
      ), // new
  1. Launch the app, navigate to that example
  2. observe that the animation is still running

Expected behavior

The animation shouldn't be running when TickerMode is off

/cc @dnfield

goderbauer avatar Oct 28 '21 17:10 goderbauer

If the animations were to be driven off a AnimationController you'd get this feature for free as AnimationControllers stop ticking when TickerMode is off.

goderbauer avatar Oct 28 '21 18:10 goderbauer

Hi @goderbauer, this should now be resolved in v0.11.14

Thanks for reporting the issue. Please reopen if you encounter an issues.

HayesGordon avatar Aug 10 '23 12:08 HayesGordon

Hey @HayesGordon, it seems like the issue is not fixed.

The ticker is stopped when ticket mode is disabled on the creation of the render object. However, afterward, the render object is attached without looking at the tickerModeEnabled.

That leads to just starting the ticker.

jaggernod avatar Apr 23 '24 10:04 jaggernod

I have created a small PR.

I have not added a test for the render object as I was not able to find an already existing test for that render object.

I hope that it is fine.

jaggernod avatar Apr 23 '24 10:04 jaggernod