在jQuery终端中,输入一系列的打字动画后,提示未显示出来。

huangapple go评论128阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月15日 18:19:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743358.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定