compile-hero icon indicating copy to clipboard operation
compile-hero copied to clipboard

Promise not compiling

Open senwmn opened this issue 4 years ago • 3 comments

HI, when trying to write a promise using async await i'm getting this error after compiling: "ReferenceError: regeneratorRuntime is not defined"

Is there a way around this or should i just avoid using a promise?

TIA

senwmn avatar Dec 18 '20 16:12 senwmn

Hi, Can you provide the complete code to be compiled?

Wscats avatar Dec 18 '20 19:12 Wscats

Yeah sure,

barba.init({
    sync: true,
    debug: true,
    transitions: [{
        async leave() {
            const done = this.async();
            pageOut();
            await delay(1000);
            done();
        },

        async enter() {
            pageIn();
        },

        async once() {
            pageIn();
        }
    }]
})


const delay = t => {
    t = t || 1000;
    return new Promise((done) => {
        setTimeout(() => {
            done();
        }, t)
    })
}

const pageIn = e => {
    const tl = gsap.timeline();
    tl.set('.content', { opacity: 0 })
    tl.to('.content', { opacity: 1 })
}

const pageOut = e => {
    const tl = gsap.timeline();
    tl.to('.content', { opacity: 0 })
}

using barba.js and gsap for transitions

senwmn avatar Dec 21 '20 10:12 senwmn

babel-polyfill (deprecated as of Babel 7.4) is required. You must also install it in order to get async/await working.

https://stackoverflow.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined

Wscats avatar Dec 24 '20 02:12 Wscats