barba.js [v2]
Barba is a small (7kb minified and compressed) and easy-to-use library that helps you creating fluid and smooth transitions between your website's pages.
It helps reducing the delay between your pages, minimizing browser HTTP requests and enhancing your user's web experience.
This is beta version, use it at your own risks!
π±
Thanks in advance for reporting bugs. #sharetheloveπ Looking for v1?
π
What's new?
- Simplified API
- Hook sytem for
transitions
andviews
- Transition resolution: declare your transitions and let Barba pick the right one
- Use of
data-barba
attributes - Sync mode
- Plugin system
@barba/router
: use of routes for transition resolution@barba/css
: automatic addition of CSS classes@barba/prefetch
: automatic pages prefetching (and caching), based on viewport@barba/head
: update your<head>
(coming soon)@barba/preset
: ready-to-use basic transitions pack (fade, slide, β¦) (coming soon)
Main changes (TL;DR)
- Barba now use
data-barba-*
attributes: - 2 main methods:
barba.init()
for transitions, views and Barba core settingsbarba.use()
for plugins (router, css, prefetch, etc.)
- Transitions:
- are plain JS objects
- are declared via the
barba.init({ transitions })
- use "hooks" corresponding to animation steps
- hooks can be synchronous or asynchronous (via
this.async()
or Promise based) - all hooks receive same
data
argument
- hooks can be synchronous or asynchronous (via
- use "rules" to select which transition to use
- default rules are
namespace
andcustom
@barba/router
addsroute
rule- they can be combined within
from
andto
properties
- default rules are
- Views:
- are plain JS objects
- are declared via the
barba.init({ views })
- use a subset of animation "hooks":
beforeAppear
,afterAppear
,beforeLeave
,afterLeave
,beforeEnter
,afterEnter
- receive the same
data
argument
- Sync mode will start
leave
andenter
transitions concurrently
Documentation
How to contribute
If you want to report a bug or if you just want to request for a new feature/improvement, please follow those instructions before.
Thanks for taking time to contribute to Barba
Contributors
Next steps
- CI setup (PR, publish, β¦)
- Write manual documentation
- Generate code documentation
- Testing, debugging, fixing, testingβ¦
- e2e testing suite
- New website