Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event when animation finishes #779

Closed
jcubic opened this issue May 19, 2022 · 1 comment
Closed

Add event when animation finishes #779

jcubic opened this issue May 19, 2022 · 1 comment
Labels
feature resolved if issue is resolved, it will be open until merge with master

Comments

@jcubic
Copy link
Owner

jcubic commented May 19, 2022

I have an idea for a new feature for jQuery Terminal

While working on Gaiman I've noticed that there is no easy way to know when to invoke the command after animation and before the promise is resolved when calling terminal::read.

What is needed is an event, maybe onAnimationEnd that can be used to read so you can call exec to fill the input:

const msg = await term.read("name? ", {
  typing: true,
  onAnimationEnd: () => {
    term.exec("Jakub", { typing: true });
  }
});

this should evaluate to string "Jakub" when both animations end.

@jcubic jcubic added the feature label May 19, 2022
jcubic added a commit that referenced this issue May 26, 2022
@jcubic
Copy link
Owner Author

jcubic commented May 26, 2022

The syntax is as follows:

(async () => {
    const name = await term.read("name? ", {
        typing: true,
        onReady: () => {
            term.exec("Jakub", { typing: true });
        }
    });
    term.echo(`You're ${name}`);
})();

onReady is a better name here because it can be used without animation.

@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label May 26, 2022
@jcubic jcubic closed this as completed Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

1 participant