Skip to content

Instantly share code, notes, and snippets.

@tiansial

tiansial/init.js Secret

Created October 12, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiansial/390aa43a71530c550c169cc9104921a6 to your computer and use it in GitHub Desktop.
Save tiansial/390aa43a71530c550c169cc9104921a6 to your computer and use it in GitHub Desktop.
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