Javascript 在完成一次旋转后,如何停止jQuery中的动画?

Javascript 在完成一次旋转后,如何停止jQuery中的动画?,javascript,jquery,Javascript,Jquery,我希望动画停止动画时,文本反应出现,停止动画后反应文本将停留在那里 //TextScramble 类文本置乱{ 建造师(el){ this.el=el this.chars='!-\\/[]{}-=+*^?#!!!!! this.update=this.update.bind(this) } setText(新文本){ const oldText=this.el.innerText const length=Math.max(oldText.length、newText.length) con

我希望动画停止动画时,文本
反应
出现,停止动画后
反应
文本将停留在那里

//TextScramble
类文本置乱{
建造师(el){
this.el=el
this.chars='!-\\/[]{}-=+*^?#!!!!!
this.update=this.update.bind(this)
}
setText(新文本){
const oldText=this.el.innerText
const length=Math.max(oldText.length、newText.length)
const promise=new promise((resolve)=>this.resolve=resolve)
this.queue=[]
for(设i=0;i=结束){
完整的++
输出+=至
}else if(this.frame>=开始){
if(!char | | Math.random()<0.28){
char=this.randomChar()
this.queue[i].char=char
}
输出+=`${char}`
}否则{
输出+=来自
}
}
this.el.innerHTML=输出
if(complete==this.queue.length){
这个。解决()
}否则{
this.frameRequest=requestAnimationFrame(this.update)
这是我的相框++
}
}
randomChar(){
返回this.chars[Math.floor(Math.random()*this.chars.length)]
}
}
//范例
常量短语=[
"判决",,
“反应”
]
const el=document.querySelector(“.text”)
const fx=新文本加扰(el)
设计数器=0
常量下一个=()=>{
fx.setText(短语[计数器])然后(()=>{
设置超时(下一步,800)
})
计数器=3%长度
}
下一步()
@import'https://fonts.googleapis.com/css?family=Roboto+单声道:100’;
html,
身体{
字体系列:“Roboto Mono”,monospace;
背景:#212121 ;;
身高:100%;
}
.集装箱{
身高:100%;
宽度:100%;
证明内容:中心;
对齐项目:居中;
显示器:flex;
}
.文本{
字号:100;
字号:28px;
颜色:#fafafa;
}
达德先生{
颜色:#7575;
}

您可以这样做:

const next = () => {
  if ((counter) < phrases.length) {
    fx.setText(phrases[counter]).then(() => {
      setTimeout(next, 800)
    })
    counter++;
  }
}