Skip to content

Commit 608a297

Browse files
committed
Add gif to readme, clear auto advance timeout before setting
1 parent 157bd7e commit 608a297

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# RPGDialogBox
22
It's literally a dialog box from some RPG
33

4+
![Sample, totally real world dialog](/readme-img/sample.gif)
5+
46
### TODO
57
- [X] Paging using newlines in input area
68
- [X] Opening/closing

app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const main = () => {
99
let autoAdvance = false;
1010
let dialogLines = [];
1111
let currentDialogLine = 0;
12+
let autoAdvanceTimeout = undefined;
1213

1314
const typewriterEventCallback = (event) => {
1415
const moreTextIcon = document.getElementById("moreTextIcon");
@@ -22,7 +23,12 @@ const main = () => {
2223
if (autoAdvance) {
2324
// Determine delay based on length of text (longer text = longer delay)
2425
let delay = 3000 + (mainDialog.innerHTML.length * 50); // 50ms/character
25-
setTimeout(() => {
26+
27+
if (autoAdvanceTimeout) {
28+
clearTimeout(autoAdvanceTimeout);
29+
}
30+
31+
autoAdvanceTimeout = setTimeout(() => {
2632
nextButton.click();
2733
}, delay);
2834
}

readme-img/sample.gif

223 KB
Loading

0 commit comments

Comments
 (0)