File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ import 'package:flare_dart/math/mat2d.dart' ;
2+
3+ import 'flare.dart' ;
4+ import 'flare_controller.dart' ;
5+
6+ /// A naiive controller that allows you to scrub through a single animation.
7+ /// Useful for wiring up progress bars or scroll based animations.
8+ class FlareProgressController extends FlareController {
9+ FlareProgressController (this .animation);
10+
11+ final String animation;
12+
13+ FlutterActorArtboard _artboard;
14+ ActorAnimation _animation;
15+
16+ @override
17+ bool advance (FlutterActorArtboard artboard, double elapsed) {
18+ return false ;
19+ }
20+
21+ @override
22+ void initialize (FlutterActorArtboard artboard) {
23+ _artboard = artboard;
24+ if (_artboard != null ) {
25+ _animation = artboard.getAnimation (animation);
26+
27+ if (_animation != null ) {
28+ _animation.apply (0.0 , _artboard, 1.0 );
29+ }
30+ }
31+ }
32+
33+ /// Updates the animation progress and triggers a render
34+ void update (double t) {
35+ if (_animation != null ) {
36+ final time = _animation.duration * t;
37+ _animation.apply (time, _artboard, 1.0 );
38+ }
39+ }
40+
41+ @override
42+ void setViewTransform (Mat2D viewTransform) {}
43+ }
You can’t perform that action at this time.
0 commit comments