英文:
Prompt not showing up after a sequence of typing animations in jQuery Terminal
问题
eth_atr_d9: function() {
this.echo('进入...', { typing: true, delay: 10 });
this.echo('文本1', { typing: true, delay: 30 });
this.echo('文本2', { typing: true, delay: 30 });
在输入此命令'eth_atr_d9'后,要回显的文本正常打印,但不会出现">"符号,但仍然允许输入另一个命令,而另一个命令也能正常运行。
我尝试更改文本的长度,但问题只发生在此命令中,其他6个命令正常工作。我在本地和codepen.io上尝试过。
英文:
eth_atr_d9: function() {
this.echo('Entering... ', { typing: true, delay: 10 });
this.echo('Text1', { typing: true, delay: 30 });
this.echo('Text2', { typing: true, delay: 30 });
On entering this command 'eth_atr_d9', the text to be echoed is printed normally but the ">" does not come, still it allows to enter another command which too works perfectly fine.
I tried changing the length of the text but the problem is occurring with only this command rest 6 commands work normally. I tried it locally and on codepen.io
答案1
得分: 0
问题在于动画是异步的。在第一个动画完成之前,你不能调用下一个动画。否则,你会得到一个奇怪的状态。
尝试类似这样的方法:
const commands = {
eth_atr_d9: async function() {
await this.echo('进入中...', { typing: true, delay: 10 });
await this.echo('文本1', { typing: true, delay: 30 });
await this.echo('文本2', { typing: true, delay: 30 });
}
};
这里有一个 CodePen 演示。
我已经将这添加到 Wiki。
英文:
The problem is that animation is asynchronous. You can't call the next animation before the first finishes. Otherwise, you will end up with an odd state.
try something like this:
const commands = {
eth_atr_d9: async function() {
await this.echo('Entering... ', { typing: true, delay: 10 });
await this.echo('Text1', { typing: true, delay: 30 });
await this.echo('Text2', { typing: true, delay: 30 });
}
};
Here is a CodePen demo.
I've added this to Wiki.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论