Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Correct way to use mojs with promise/async? #221

@uduse

Description

@uduse

I want to play an animation and wait until it finishes. I checked the docs and tutorials and I did not find an API that returns a promise or something.

It seems there's no related discussion here so I would like it to ask if there's a standard way of doing this?

What I am doing now is wrapping it in a promise and it works fine:

const burstPromise = new Promise(resolve => {
    const burst = new mojs.Burst({
        radius: {30: 120},
        count: 10,
        children: {
            duration: 3000,
        },
        onComplete() {
            resolve();
        }
    });
    burst.play();
});

await burstPromise;

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurefeature request to implement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions