Skip to content

Instantly share code, notes, and snippets.

@ebhoren
Created August 2, 2020 20:34
Show Gist options
  • Save ebhoren/3a153fbe9d4d44a3b680f92c6f443471 to your computer and use it in GitHub Desktop.
Save ebhoren/3a153fbe9d4d44a3b680f92c6f443471 to your computer and use it in GitHub Desktop.
Body classnames manipulation during Barba.js transition
barba.hooks.beforeEnter(({ next }) => {
const parser = new DOMParser();
const source = parser.parseFromString(next.html, "text/html");
const body = source.querySelector('body');
const classnames = body.getAttribute('class');
console.log(classnames);
if( classnames ) document.querySelector('body').setAttribute('class', classnames);
});
@ebhoren
Copy link
Author

ebhoren commented Aug 2, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment