Pisanie animacji w 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