I would like to display blank character spaces and line breaks in my Terminal Text Effect function. Right now it will only display one blank space and wait until the next character, also it will completely ignore any type of line breaks in my string :/
Here's my html :
<div class="console-container">
<span id="text"></span>
<div class="console-underscore" id="console"></div>
</div>
and the javascript:
consoleText(
[
"hugo@Hugos-MacBook-Pro ~ % ",
"All projects made with love",
],
"text"
);
function consoleText(words, id) {
var visible = true;
var con = document.getElementById("console");
var letterCount = 1;
var x = 1;
var waiting = false;
var target = document.getElementById(id);
window.setInterval(function () {
if (letterCount === 0 && waiting === false) {
waiting = true;
target.innerHTML = words[0].substring(0, letterCount);
window.setTimeout(function () {
var usedWord = words.shift();
words.push(usedWord);
x = 1;
letterCount += x;
waiting = false;
}, 1000);
} else if (letterCount === words[0].length + 1 && waiting === false) {
waiting = true;
window.setTimeout(function () {
x = -1;
letterCount += x;
waiting = false;
}, 1000);
} else if (waiting === false) {
target.innerHTML = words[0].substring(0, letterCount);
letterCount += x;
}
}, 50);
}
Sorry if it seems like a stupid question, i'm quite new to programming :)
Thank a lot !