D
D
Dmitry2021-04-28 15:58:20
JavaScript
Dmitry, 2021-04-28 15:58:20

What is the correct way to add offset and delay for text with appear.js?

Please advise how to correctly add offset and delay to this code? Now the appearance and typing starts just when it is reached on the page, you need to add offset and delay, and so that they can be added separately. The appear.js plugin is used from here .

$(function() {
      var el = document.getElementById('typewriter'),
        str = el.innerHTML,
        i = 0,
        isTag,
        text;
    
      function type() {
        text = str.slice(0, ++i);
        if (text === str) return;
    
        el.innerHTML = text;
    
        var char = text.slice(-1);
        if (char === '<') isTag = true;
        if (char === '>') isTag = false;
    
        if (isTag) return type();
        setTimeout(type, 60);
      };
    
      $(el).appear(type);
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question