Skip to content

Commit

Permalink
Fix delayed output
Browse files Browse the repository at this point in the history
  • Loading branch information
qwbarch committed Dec 10, 2023
1 parent 8902c50 commit ff8dc64
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Halogen/Typewriter.purs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,15 @@ typewriter = mkComponent { initialState, render, eval }
forkDispatch UpdateCursor
forkDispatch UpdateState
UpdateCursor -> get >>= \state ->
if state.running then do
when state.running $ do
cursorHidden %= not
sleep identity cursorDelay
handleAction UpdateCursor
else do
cursorHidden .= true
raise Finished
UpdateState -> get >>= \state ->
case head state.words of
Nothing -> void $ modify $ _ { running = false, cursorHidden = true }
Nothing -> do
void $ modify $ _ { running = false, cursorHidden = true }
raise Finished
Just word -> do
case state.mode of
Typing ->
Expand All @@ -172,7 +171,7 @@ typewriter = mkComponent { initialState, render, eval }
mode .= Deleting
sleep identity pauseDelay
Just letter -> do
coefficient <- liftEffect $ state.jitter
coefficient <- liftEffect state.jitter
sleep (_ * coefficient) typeDelay
-- Add the next letter to outputText.
outputText <>= singleton letter
Expand Down

0 comments on commit ff8dc64

Please sign in to comment.