File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# RPGDialogBox
22It'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
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments