“Mengetik Animasi di JS” Kode Jawaban

Mengetik Animasi di JS

// 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

JS mengetik animasi

<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

Jawaban yang mirip dengan “Mengetik Animasi di JS”

Pertanyaan yang mirip dengan “Mengetik Animasi di JS”

Lebih banyak jawaban terkait untuk “Mengetik Animasi di JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya