xxxxxxxxxx
--luau
local strings = "this is a string"
for i = 1, string.len(strings) do
print(string.sub(strings,1,i))
wait(0.2)
end
xxxxxxxxxx
// this function performs a typewriter effect on an element from the HTML DOM
function TypeWriter(target, text, delay, clearText = false) {
if (target.textContent === text) {
return;
}
if (clearText) {
target.textContent = "";
}
let _delay = 0;
for (let i = 0; i < text.length; i++) {
_delay += delay;
window.setTimeout(function() {
target.textContent += text[i];
}, _delay);
}
}
xxxxxxxxxx
<div class="wrapper">
<div class="typing-demo">
Zrubix Solution PVT LIMIted
</div>
</div>
.wrapper {
height: 100vh;
}
.typing-demo {
width: 27ch;
animation: typing 2s steps(22), blink .5s step-end infinite alternate;
white-space: nowrap;
overflow: hidden;
border-right: 3px solid;
font-family: monospace;
font-size: 2em;
}
@keyframes typing {
from {
width: 0
}
}
@keyframes blink {
50% {
border-color: transparent
}
}