fix: handle multiple clicks on typing animations;
This commit is contained in:
parent
1cb8e8ab2c
commit
2571771f70
4 changed files with 32 additions and 2 deletions
|
|
@ -62,14 +62,25 @@ function renderPosts(topic) {
|
|||
postMapping.get(topic).forEach((postName) => {
|
||||
const post = document.createElement("div");
|
||||
post.classList.add("post");
|
||||
post.textContent = postName;
|
||||
|
||||
const link = document.createElement("a");
|
||||
post.classList.add("post");
|
||||
link.href = `/posts/${postName.replace(/\s+/g, "-").toLowerCase()}.html`;
|
||||
link.textContent = postName;
|
||||
|
||||
post.appendChild(link);
|
||||
posts.appendChild(post);
|
||||
});
|
||||
}
|
||||
|
||||
let typing = false;
|
||||
|
||||
function typechars(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (typing) return;
|
||||
typing = true;
|
||||
|
||||
const topic = e.target.textContent;
|
||||
const terminalText = ` ${topic.toLowerCase()}/`;
|
||||
const terminalPrompt = document.querySelector(".prompt");
|
||||
|
|
@ -84,6 +95,7 @@ function typechars(e) {
|
|||
setTimeout(typechar, delay / terminalText.length);
|
||||
} else {
|
||||
renderPosts(topic);
|
||||
typing = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue