Events

During all the lifecycle of the page transition, barba will emit a series of events, with useful information:

Name Arguments When
linkClicked HTMLElement, MouseEvent The user click on a link elegible for PJAX.
initStateChange currentStatus The link has just been changed.
newPageReady currentStatus, prevStatus, HTMLElementContainer, newPageRawHTML The new container has been loaded and injected in the wrapper.
transitionCompleted currentStatus[, prevStatus] The transition has just finished and the old Container has been removed from the DOM.

currentStatus and prevStatus are plain objects with the url of the page and eventually the namespace.

To listen for an event, it's as simple as:

Barba.Dispatcher.on(eventName, function() {
                    //your listener
});

Example

Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container) {
});