Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Smoothstate.js | 4,426 | 36 | 3 | 2 years ago | 7 | June 03, 2015 | 124 | mit | CSS | |
Unobtrusive page transitions with jQuery. | ||||||||||
Swup | 3,936 | 17 | 6 | 13 hours ago | 94 | August 23, 2022 | 13 | mit | TypeScript | |
:tada: Complete, flexible, extensible, and easy-to-use page transition library for your server-side rendered website. | ||||||||||
Animsition | 3,749 | 21 | 1 | 4 years ago | 8 | April 26, 2016 | 76 | mit | CSS | |
A simple and easy jQuery plugin for CSS animated page transitions. | ||||||||||
Elementtransitions | 1,532 | 2 | 7 years ago | July 16, 2022 | 7 | CSS | ||||
Simple transitions for web pages | ||||||||||
Gatsby Plugin Transition Link | 542 | 73 | 19 | 3 months ago | 95 | October 17, 2020 | 125 | JavaScript | ||
A link component for page transitions in gatsby | ||||||||||
Next Page Transitions | 540 | 65 | 9 | 5 months ago | 9 | March 29, 2019 | 90 | mit | JavaScript | |
Simple and customizable page transitions for Next.js apps | ||||||||||
React Tiger Transition | 477 | 1 | 5 months ago | 27 | February 14, 2020 | 40 | mit | JavaScript | ||
Full page transitions with react-router. | ||||||||||
Nextjs Page Transitions | 453 | 2 years ago | 1 | mit | JavaScript | |||||
Travel App, Native-like Page Transitions (:atom: with React & Next.js) | ||||||||||
V Shared Element | 390 | 1 | 6 days ago | 18 | July 07, 2021 | 5 | mit | TypeScript | ||
Declarative shared-element transitions for Vue.js | ||||||||||
Flutter_villains | 357 | 9 | 9 months ago | 11 | August 26, 2022 | 5 | mit | Dart | ||
Flexible and easy to use page transitions. |
(Profile image from: https://unsplash.com/photos/pAs4IM6OGWI)
Check out the article.
You keep seeing beautiful page transitions but you think to yourself those are too much work?
Fear no more, villains are here to save you!
When doing animations when a page transition occurs you'd usally define an AnimationController
in the initState()
and start it there. You'd also have to wrap your widgets in AnimatedWidgets
to react to the AnimationController
. Besides this being a lot of boilerplate code which clogs up you precious widgets, animating on exit isn't as trivial.
Using this library you just wrap your widget you'd like to be animated when a page transition occurs in a Villain
and everything is handled automatically.
dependencies:
flutter_villains: "^1.2.1"
Run packages get and import:
import 'package:flutter_villains/villain.dart';
Define animations to play when a page is opened.
Villain(
villainAnimation: VillainAnimation.fromBottom(
relativeOffset: 0.4,
from: Duration(milliseconds: 100),
to: Duration(seconds: 1),
),
animateExit: false,
secondaryVillainAnimation: VillainAnimation.fade(),
child: Divider(
color: Colors.black,
height: 32.0,
),
),
That's it. No TickerProvider
s, no AnimationController
s, no boilerplate, no worries.
Remember the StaggeredAnimation tutorial? This is using SequenceAnimation internally and there is therefore no need to specify durations as portions of a time-frame. It just works.
With this basic setup the Divider
fades in and moves up when a page transition occures (don't forget the VillainTransitionObserver
more on that under Code).
The animation you'd like to use is not premade? Make it yourself with a few lines of code!
static VillainAnimation fade(
{double fadeFrom = 0.0,
double fadeTo = 1.0,
Duration from = Duration.zero,
Duration to: _kMaterialRouteTransitionLength,
Curve curve: Curves.linear}) =>
VillainAnimation(
from: from,
curve: curve,
to: to,
animatable: Tween<double>(begin: fadeFrom, end: fadeTo),
animatedWidgetBuilder: (animation, child) {
return FadeTransition(
opacity: animation,
child: child,
);
});
Every VillainAnimation
needs an Animatable
(most of the time it's a Tween
) and an AnimatedWidget
. Everything else is handled automatically.
There are two way of playing your villains.
MaterialApp
return new MaterialApp(
navigatorObservers: [new VillainTransitionObserver()],
VillainController.playAllVillains(context);
You can play up to two animations per Villain
. You can always wrap Villains inside each other for infinite animations!
Villain(
villainAnimation: VillainAnimation.fromBottomToTop(0.4, to: Duration(milliseconds: 150)),
animateExit: false,
secondaryVillainAnimation: VillainAnimation.fade,
child: Text(
"Hi",
style: Theme.of(context).textTheme.body1,
),
),
Define whether the villain should play on entrance/ exit.
animateEntrance: true,
animateExit: true,
When using the VillainController
manually, it checks this bool to determine whether it should animate.
static Future playAllVillains(BuildContext context, {bool entrance = true})
Villains entering the page are decoupled from the page transition, meaning they can be as long as they want. On the other hand, if a villain leaves the page, the animation is driven by the page transition. This means:
Take a look at the example folder for three nice examples.
The villain framework takes care of:
In contrast to real world villains, these villains are very easy to handle.
Currenty there are no controllers implemented to play individual villains by themselves. If you'd like to have that implemented I opened an issue discussing it. Check it out!
Icon from https://icons8.com/
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.