This commit is contained in:
tree 2023-02-16 12:58:21 +01:00
rodič d8a3cd1063
revize 2c3abc1ece
1 změnil soubory, kde provedl 5 přidání a 2 odebrání

Zobrazit soubor

@ -21,12 +21,15 @@ export function animateText (ev) {
const orig = ev.target.getAttribute('data-text')
const steps = orig.length
const random = rand(orig.length)
const genRand = (pos = 0, len = null) => orig.substring(pos, len).split(' ').map(x => rand(x.length)).join(' ')
const random = genRand(0, orig.length)
ev.target.innerHTML = random
for (let i = 0; i <= steps; i++) {
setTimeout(() => {
ev.target.innerHTML = orig.substring(0, i) + rand(orig.length - i)
ev.target.innerHTML = orig.substring(0, i) + genRand(i, orig.length)
console.log(ev.target.innerHTML)
if (i === steps) {
ev.target.setAttribute('data-animate', "0")