简体   繁体   English

无法让 Barba JS 转换来处理页面更改

[英]Cannot get Barba JS transition to work on page change

I'm trying to get Barba JS , alongside GSAP , implemented on my React website.我正在尝试在我的React网站上实现Barba JSGSAP

For reference, I have followed this video tutorial here , this tutorial of course, is not in React .作为参考,我在这里关注了这个视频教程,这个教程当然不在React

Here is my folder structure which showcases all of the relevant files for this transition effect:这是我的文件夹结构,它展示了此过渡效果的所有相关文件:

 theme public index.html src components Header Header.js pages Homepage Contact utils anim.js helpers.js App.js index.js

I have the following packages installed:我安装了以下软件包:

Current results当前结果

  • No console errors and no compilation errors.没有控制台错误,也没有编译错误。

  • When switching pages, there's no transition.切换页面时,没有过渡。 It almost feels like barba isn't initiated.几乎感觉barba没有启动。

Demo:演示:

As the demo involves a few files, I have created a codesandbox here .由于演示涉及几个文件,我在这里创建了一个代码沙盒

Edit:编辑:

Have updated my barba transition code and have added debug: true .更新了我的barba转换代码并添加了debug: true Then, when hovering over my contact page button, the console shows the error: [@barba/core] Error: Fetch error at XMLHttpRequest.o.onerror ?然后,将鼠标悬停在我的联系页面按钮上时,控制台会显示错误: [@barba/core] Error: Fetch error at XMLHttpRequest.o.onerror ?

 import { pageTransition } from "./helpers"; import barba from '@barba/core'; export function delay(n) { n = n || 2000; return new Promise((done) => { setTimeout(() => { done(); }, n); }); } barba.init({ debug: true, sync: true, transitions: [ { async leave(data){ const done = this.async(); pageTransition(); await delay(1000); done(); } } ] });

I have since concluded that Barba JS is not compatible with React.从那以后我得出结论,Barba JS 与 React 不兼容。 Seems like the library needs updating to work with React Router .似乎该库需要更新才能与React Router

More details here更多细节在这里

Dificult to say but you can set debug: true, inside the initialization of barba so it will spit out logs of whats happening ;)很难说,但你可以在 barba 的初始化中设置 debug: true,这样它就会吐出正在发生的事情的日志;)

barba.init({ debug: true, sync: false, //views das paginas views: [{..... barba.init({ debug: true, sync: false, //views das paginas views: [{.....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM