I'm using barba.js and locomotive scroll together, I have overlay transition which work when I click the menu link (page2) to go to another page, but once that is down I cant scroll down when, I added the below code
barba.hooks.beforeLeave((data) => {
scroll.destroy();
});
barba.hooks.after((data) => {
scroll.init();
});
I am still getting the same result, kindly help fix this
<body data-barba="wrapper">
<div class="overlayCover"></div>
<ul>
<li><a href="page1.html">Page 1</a></li>
<li><a href="page2.html">Page 2</a></li>
</ul>
<main data-barba="container" data-barba-namespace="page1">
<div class="o-scroll">
<div data-scroll-container>
content here ....
</div>
</div>
</div>
</body>
Full script below
const scroll = new locomotiveScroll({
el: document.querySelector('.o-scroll'),
smooth: true
});
barba.hooks.enter(() => {
window.scrollTo(0, 0);
});
barba.hooks.beforeLeave((data) => {
scroll.destroy();
});
barba.hooks.after((data) => {
scroll.init();
});
barba.init({
sync: true,
transitions: [{
async leave(data) {
const done = this.async();
pageTransition();
await delay(1500);
done();
},
async enter(data) {
contentAnimation();
},
async once(data) {
contentAnimation();
}
}]
});
Thanks