-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84535f2
commit 81edadb
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flare_dart/math/mat2d.dart'; | ||
|
||
import 'flare.dart'; | ||
import 'flare_controller.dart'; | ||
|
||
/// A naiive controller that allows you to scrub through a single animation. | ||
/// Useful for wiring up progress bars or scroll based animations. | ||
class FlareProgressController extends FlareController { | ||
FlareProgressController(this.animation); | ||
|
||
final String animation; | ||
|
||
FlutterActorArtboard _artboard; | ||
ActorAnimation _animation; | ||
|
||
@override | ||
bool advance(FlutterActorArtboard artboard, double elapsed) { | ||
return false; | ||
} | ||
|
||
@override | ||
void initialize(FlutterActorArtboard artboard) { | ||
_artboard = artboard; | ||
if (_artboard != null) { | ||
_animation = artboard.getAnimation(animation); | ||
|
||
if (_animation != null) { | ||
_animation.apply(0.0, _artboard, 1.0); | ||
} | ||
} | ||
} | ||
|
||
/// Updates the animation progress and triggers a render | ||
void update(double t) { | ||
if (_animation != null) { | ||
final time = _animation.duration * t; | ||
_animation.apply(time, _artboard, 1.0); | ||
} | ||
} | ||
|
||
@override | ||
void setViewTransform(Mat2D viewTransform) {} | ||
} |