【问题标题】:Disable typewriter function if already typing on contenteditable如果已经在 contenteditable 上打字,则禁用打字机功能
【发布时间】:2022-01-14 19:59:18
【问题描述】:

我正在使用 typewriter.js 和 contenteditable="true"。但是我的问题是,当我输入输入时,我的文本将使用打字机占位符展开。在 contenteditable 中输入文本后,如何禁用打字机?这是我的代码

<div id="quote__text" contenteditable="true">


var app = document.getElementById('quote__text');
var typewriter = new Typewriter(app, {
    loop: true
});

typewriter.typeString('TYPE HERE TO SET GOAL')
    .pauseFor(2500)
    .deleteAll()
    .typeString('GOAL 1')
    .pauseFor(2500)
    .deleteChars(7)
    .typeString('GOAL 2')
    .pauseFor(2500)
    .start();

【问题讨论】:

    标签: html jquery css


    【解决方案1】:

    尝试在用户输入文本时停止库

    const editor = document.getElementById("quote__text");
    
    editor.addEventListener("input", stop);
    
    function stop(e) {
        typewriter.stop()
    }
    

    【讨论】:

      猜你喜欢
      • 2018-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多