Skip to content

Commit

Permalink
Merge pull request #8 from JamesManningR/fix/finalIterationReset
Browse files Browse the repository at this point in the history
Conditionally checked the complete state to decide play method
  • Loading branch information
JamesManningR authored Sep 23, 2022
2 parents a0fea29 + fb870b0 commit 018e7df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/UseTypewriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,14 @@ export function useTypewriter(
resetWord();
break;
case TypewriterState.Complete:
// If we want to play and the typewriter is complete, we need to reset the typewriter.
reset();
// If our complete state is a full word
if (typedLength.value !== 0) {
// We need to start the word deleting
resetWord();
} else {
// Otherwise we need to start the array again
reset();
}
break;
}
}
Expand All @@ -306,7 +312,7 @@ export function useTypewriter(
currentAction.value = TypewriterState.Complete;
pause();
isPausingAtEnd.value = false;
iteration.value = 1
iteration.value = 1;

if (finishEmpty.value) {
stringIndex.value = 0;
Expand Down

0 comments on commit 018e7df

Please sign in to comment.