- Notifications
You must be signed in to change notification settings - Fork5
prateekbh/liquid-route
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
npm i -D liquid-routeThis is a collection of route element and animation objects based onelement.animate. Which will make it super easy for you to do animated routing.
This mainly consist of the following animation objects
- FadeAnimation: Next route will fade in and current will fade out.
- PopAnimation: Next route will pop from center and current route will implode.
- SlideLeftAnimation: Next route will slide from right while current one slides to left.
- PushNSlideAnimation: Routes will scale down and slide.
- AppearFromBottomAnimation: Next route will fade and appear from bottom and sit on top of current route.
- AppearFromRightAnimation: Next route will fade and appear from right and sit on top of current route.
liquid-route is the route component which you would need to use in order animate between routes. It takes a prop named animator which is a animation object
importRouterfrom'preact-router';importLiquidRoute,{FadeAnimation,PopAnimation}from'liquid-route';import'liquid-route/style.css';importHomefrom'./Components/Home/Home.jsx';...return(<Router><LiquidRouteanimator={FadeAnimation}path="/"component={Home}/><LiquidRouteanimator={PopAnimation}path="/profile"getComponent={()=>{returnSystem.import('./Components/Profile/Profile.jsx').then(module=>module.default);}}/><LiquidRouteanimator={PopAnimation}path="/profile/:pid"getComponent={()=>{returnSystem.import('./Components/Profile/Profile.jsx').then(module=>module.default);}}/></Router>);
Animator object is a javascript object which exposes two methods
getEntryAnimation- returns animation object used to play entry animation of a routegetExitAnimation- returns animation object used to playexitentry animation of a route
Both of the above ☝ methods return an object having the following propertiesa. animation: array of animation object used to play the entry/exit effectb. options: an object of options taken byelement.animate api.
According toMDN Web Animation is still in working draft status and only a few browsers support it, however there's apolyfill might come in handy.
While some basic animator objects come with the bundle,here is where the most of the transition inspiriation is drawn from.
Send PR if you wanna add new animators in the repo, happy to include 😊.
In order for the transitions to work, please declare all routes asliquid-route.
P.S. Tried and tested most of the animations are easily doable with this route element.
About
Animated routing FTW
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.
