我已经尝试过 barba.js 和 locomotive-scroll 工作(我也尝试过 scrollmagic),但我没有让它正常工作。如果我将 locomotive-scroll 放在 about 页面上并重新加载浏览器,它可以工作,但如果我从那里转到主页并返回 about 页面,它会给我一个错误并停止工作。与其他脚本没有问题,这就是为什么我认为一定有一些不兼容的原因。我尝试了很多方法,但它们都给了我一个错误。最后一个是:
$(function () {
barba.init({
sync: true,
cacheIgnore: false,
transitions: [
{
async leave(data) {
const done = this.async();
pageTransition();
await delay(1000);
done();
},
async enter(data) {
contentAnimation();
},
async once(data) {
contentAnimation();
},
},
],
views: [{
namespace: 'about-section',
beforeEnter({ next }) {
let script = document.createElement('script');
script.src = 'http://127.0.0.1:5000/locomotive-scroll.js';
next.container.appendChild(script);
}
}]
});
});