Views

Views allows you to have some logic related to the content of a namespace.
It’s a good place to init or destroy things, making the code run in a confined place.

They use a subset of base hooks.

Syntax

1
2
3
4
5
6
7
8
9
10
11
12
13
barba.init({
views: [{
namespace: 'index',
beforeLeave(data) {
// do something before leaving the current `index` namespace
}
}, {
namespace: 'contact',
beforeEnter(data) {
// do something before entering the `contact` namespace
}
}]
});

Keep in mind that a view is always related to a unique namespace.