Skip to content

Instantly share code, notes, and snippets.

@tiansial tiansial/init.js Secret
Created Oct 12, 2018

Embed
What would you like to do?
import Barba from 'barba.js/dist/barba';
export default function (routes) {
Barba.Pjax.Dom.wrapperId = 'barba-wrapper';
Barba.Pjax.Dom.containerClass = 'barba-container';
// Fire Barba.js
Barba.Pjax.start();
Barba.Prefetch.init();
Barba.Dispatcher.on('transitionCompleted', function() {
// Set new classes from #af-classes to body
$('body').attr('class', $('main').attr('class'));
// Fire routes again after new content loaded
routes.loadEvents();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.