elegant_spring_animation 1.0.0 elegant_spring_animation: ^1.0.0 copied to clipboard
A package that provides an intuitive API for using spring animations.
Make your animations feel natural with spring animations.
This package lets you easily create spring physics-based animation curves, and use them wherever you want.
Getting started #
Add elegant_spring_animation
as a dependency in your pubspec.yaml file:
dependencies:
elegant_spring_animation: ^1.0.0
Usage #
Basic usage #
Pass the duration of your animation in the constructor, and that's it.
Note: be sure to pass the correct duration, as internal calculations are based on the duration. (If you pass a different duration than the actual duration of the animation, the resulting curve won't be ideal)
final Duration _duration = const Duration(milliseconds: 1000);
late AnimationController _animationController;
late Curve _elegantCurve;
@override
void initState() {
super.initState();
_animationController = AnimationController(vsync: this, duration: _duration);
_elegantCurve = ElegantSpring(duration: _duration);
}
Customizing the bounciness #
There is an optional bounce
parameter, which has a default value of 0 (no bounce).
You can provide a value between -1 and 1. Higher the value, bouncier the animation. (Negative values may result in an unnatural motion).
_elegantCurve = ElegantSpring(duration: _duration, bounce: 0.25);