Violets-Purgatory/static/themes/code/script.js

29 lines
756 B
JavaScript
Raw Normal View History

2024-06-26 04:56:54 -05:00
function typeWriter(elem, delay) {
var elemText = elem.text().split('')
elem.text('_'.repeat(elemText.length))
var i = 0
function nextLetter() {
elem.text(elemText.slice(0, i).join('') + '_'.repeat(elemText.length - i))
if (i < elemText.length) {
setTimeout(() => {
i++
nextLetter()
}, 20)
}
}
setTimeout(() => {
if (elem.text() == '_'.repeat(elemText.length)) {
nextLetter()
}
}, delay);
2024-06-26 04:56:54 -05:00
}
2024-06-28 22:26:45 -05:00
// $(document).ready(() => {
// var i = 0
// var arr = $("span").each((_, item) => {
// if ($(item).text().length > 0) {
// i++
// typeWriter($(item), i * 150)
// }
// })
// })