简体   繁体   English

Barba.js 转换多个页面

[英]Barba.js Transition Multiple Pages

I am experimenting on Barba.js.我正在试验 Barba.js。 What i am trying to do is when transitioning from page to page, i want to see the animation of 3 colour-pages to load up first as a canvas effect.我想要做的是当从一个页面转换到另一个页面时,我想看到 3 个彩色页面的 animation 首先加载为 canvas 效果。 Unfortunately, only the first canvas happens on load but the other three are non-existent.不幸的是,只有第一个 canvas 发生在负载上,而其他三个则不存在。 I tried a few combinations in main.js, i show you one of them.我在 main.js 中尝试了一些组合,我向您展示其中一种。

You can see this live here你可以在这里看到这个

$(function () {
    barba.init({
        sync: true,

        transitions: [
            {
                async leave(data) {
                    const done = this.async();

                    pageTransition();
                    await delay(1000);


                    pageTransitionTwo();
                    await delay(1000);


                    pageTransitionThree();
                    await delay(1000);
                    done();
                },

                async enter(data) {
                    contentAnimation();
                },

                async once(data) {
                    contentAnimation();
                },
            },
        ],
    });
});

How can i run loading-screen-one, loading-screen-two & loading-screen-three with a difference delay, the one after the other with barba.js?如何以不同的延迟运行加载屏幕一、加载屏幕二和加载屏幕三,一个接一个地使用 barba.js?

If i have understood you correctly, your page transition consists of some overlay changing its color 3 times, but it is only changing its color once?如果我对您的理解正确,您的页面过渡包括一些覆盖改变其颜色 3 次,但它只改变它的颜色一次?

If so, i think the problem is that you are calling done() already after 1000 milliseconds because of your first call of await delay(1000) .如果是这样,我认为问题在于您在第一次调用await delay(1000)之后已经在 1000 毫秒后调用done() ) 。 Calling done will basically tell Barba that the next Page can be loaded into the DOM and the rest of your code in leave() is probably not being executed.调用 done 基本上会告诉 Barba 可以将下一页加载到 DOM 中,并且您在leave()中的代码的 rest 可能没有被执行。

this works for me这对我有用

transitions: [{
    name: 'transition-name',
    async leave(data) {
        const done = this.async();

                changePage();
                await delay(1000);
                done()
    },
    async enter(data) {
        
    //    return enterAnimation()
    }
  }]

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

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