uncommented typewriter section as accidentally commented it

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
2021-08-01 12:56:55 +01:00
parent 10a5117eb1
commit 525f597a54
2 changed files with 44 additions and 44 deletions
+43 -43
View File
@@ -39,47 +39,47 @@ window.onscroll = () =>
});
};
// document.addEventListener('DOMContentLoaded', () =>
// {
// // array with texts to type in typewriter
// var dataText = [ "full stack developer", "web designer", "student", "gamer", "drummer"];
//
// // type one text in the typwriter
// // keeps calling itself until the text is finished
// function typeWriter(text, i, fnCallback) {
// // chekc if text isn't finished yet
// if (i < (text.length)) {
// // add next character to h1
// document.querySelector("header div h1").innerHTML = text.substring(0, i+1) +'<span aria-hidden="true">_</span>';
//
// // wait for a while and call this function again for next character
// setTimeout(function() {
// typeWriter(text, i + 1, fnCallback)
// }, 100);
// }
// // text finished, call callback if there is a callback function
// else if (typeof fnCallback == 'function') {
// // call callback after timeout
// setTimeout(fnCallback, 700);
// }
// }
// // start a typewriter animation for a text in the dataText array
// function StartTextAnimation(i) {
// if (typeof dataText[i] === 'undefined'){
// setTimeout(function() {
// StartTextAnimation(0);
// }, 1500);
// // StartTextAnimation(0);
// }
// else if (i < dataText[i].length) {
// // text exists! start typewriter animation
// typeWriter(dataText[i], 0, function(){
// // after callback (and whole text has been animated), start next text
// setTimeout(StartTextAnimation, 1500, i + 1);
// });
// }
// }
// // start the text animation
// StartTextAnimation(0);
// });
document.addEventListener('DOMContentLoaded', () =>
{
// array with texts to type in typewriter
var dataText = [ "full stack developer", "web designer", "student", "gamer", "drummer"];
// type one text in the typwriter
// keeps calling itself until the text is finished
function typeWriter(text, i, fnCallback) {
// chekc if text isn't finished yet
if (i < (text.length)) {
// add next character to h1
document.querySelector("header div h1").innerHTML = text.substring(0, i+1) +'<span aria-hidden="true">_</span>';
// wait for a while and call this function again for next character
setTimeout(function() {
typeWriter(text, i + 1, fnCallback)
}, 100);
}
// text finished, call callback if there is a callback function
else if (typeof fnCallback == 'function') {
// call callback after timeout
setTimeout(fnCallback, 700);
}
}
// start a typewriter animation for a text in the dataText array
function StartTextAnimation(i) {
if (typeof dataText[i] === 'undefined'){
setTimeout(function() {
StartTextAnimation(0);
}, 1500);
// StartTextAnimation(0);
}
else if (i < dataText[i].length) {
// text exists! start typewriter animation
typeWriter(dataText[i], 0, function(){
// after callback (and whole text has been animated), start next text
setTimeout(StartTextAnimation, 1500, i + 1);
});
}
}
// start the text animation
StartTextAnimation(0);
});