Skip to content

Instantly share code, notes, and snippets.

@ebhoren
ebhoren / barba
Created August 2, 2020 20:34
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);
});