“Animation in JS tippen” Code-Antworten

Animation in JS tippen

// typing animation in js:
//copy the following code:
const sleep = (milliseconds) => {
  return new Promise(resolve => setTimeout(resolve, milliseconds))
}

const applyTypingAnimation = async (element, delay) => {
  const stringToWrite= element.innerText;
  element.innerHTML= "";
  let refill= "";
  const cursorHTML= "▮";
  for (character of stringToWrite) {
    refill+= character;
    await sleep(delay)
    element.innerHTML= refill+cursorHTML;
  }
}

// calling the function:
applyTipingAnimation(/*your element*/, /*your delay*/)
Cloudy Caribou

Animiertes Tippen JS

<script src="https://unpkg.com/typewriter-effect@latest/dist/core.js"></script>
var app = document.getElementById('app');

        var typewriter = new Typewriter(app, {
            loop: true,
            delay: 75,
        });

        typewriter
            .pauseFor(500)
            .typeString('Websites')
            .pauseFor(500)
            .deleteChars(9)
            .pauseFor(500)
            .typeString('Messenger')
            .pauseFor(500)
            .deleteChars(9)
            .pauseFor(500)
            .typeString('Instagram')
            .pauseFor(500)
            .deleteChars(9)
            .pauseFor(500)
            .typeString('Whats App')
            .pauseFor(500)
            .deleteChars(9)
            .pauseFor(1000)
            .start();
Anthony Smith

Ähnliche Antworten wie “Animation in JS tippen”

Fragen ähnlich wie “Animation in JS tippen”

Weitere verwandte Antworten zu “Animation in JS tippen” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen