mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-04-21 05:11:53 +02:00
feat: 테마 타이핑 스크립트 작성
This commit is contained in:
parent
ff5b884c85
commit
c3acfb006f
1 changed files with 43 additions and 0 deletions
|
@ -174,4 +174,47 @@
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
var typeText = document.querySelector(".typeText")
|
||||||
|
var textToBeTyped = "Hello, World"
|
||||||
|
var textToBeTypedArr = ["Java", "Spring", "Rust", "Kotlin"]
|
||||||
|
var index = 0, isAdding = true, textToBeTypedIndex = 0
|
||||||
|
|
||||||
|
function playAnim() {
|
||||||
|
setTimeout(function () {
|
||||||
|
// set the text of typeText to a substring of the text to be typed using index.
|
||||||
|
typeText.innerText = textToBeTypedArr[textToBeTypedIndex].slice(0, index)
|
||||||
|
if (isAdding) {
|
||||||
|
// adding text
|
||||||
|
if (index > textToBeTypedArr[textToBeTypedIndex].length) {
|
||||||
|
// no more text to add
|
||||||
|
isAdding = false
|
||||||
|
//break: wait 2s before playing again
|
||||||
|
setTimeout(function () {
|
||||||
|
playAnim()
|
||||||
|
}, 2000)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
// increment index by 1
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// removing text
|
||||||
|
if (index === 0) {
|
||||||
|
// no more text to remove
|
||||||
|
isAdding = true
|
||||||
|
//switch to next text in text array
|
||||||
|
textToBeTypedIndex = (textToBeTypedIndex + 1) % textToBeTypedArr.length
|
||||||
|
} else {
|
||||||
|
// decrement index by 1
|
||||||
|
index--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// call itself
|
||||||
|
playAnim()
|
||||||
|
}, isAdding ? 120 : 60)
|
||||||
|
}
|
||||||
|
// start animation
|
||||||
|
playAnim()
|
||||||
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue