Feature: Add nextStringDelay functionality #619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Title: Add
nextStringDelay
Option for Smoother String Transitions in Typed.jsPR Description:
Requirements
Have you viewed your changes locally on the demos page, located on https://github.com/mattboldt/typed.js/blob/master/index.html?
Yes, I’ve tested the changes locally by adding a new demo to my fork’s
index.html
and viewing it in Chrome and Safari.If necessary, have you added a new demo to the index.html list of demos? If it's an improvement or small addition, have you added it to an existing demo on the demos page?
I’ve added a new demo to
index.html
in my fork to showcase thenextStringDelay
feature. The demo uses a simple loop withnextStringDelay: 1500
to demonstrate the smoother transition between strings.If applicable, have you created a fork of the following JSFiddle with your branch's code and your new feature showcased?
Yes, I’ve created a fork of the JSFiddle (https://jsfiddle.net/mattboldt/1xs3LLmL/) with my branch’s code included:
The JSFiddle demonstrates the feature with
nextStringDelay: 1500
, showing a pause between strings in a looping animation.Description of the Change
This PR adds a new
nextStringDelay
option to Typed.js, which introduces a customizable delay (in milliseconds) before typing the next string in the sequence. The feature enhances control over the animation’s pacing by allowing a pause after backspacing is completed, before typing begins again.Key changes:
nextStringDelay
tosrc/defaults.js
with a default value of0
(no delay).src/typed.js
to apply the delay in thebackspace
method (after backspacing completes) andinitFadeOut
method (after fading out forfadeOut: true
), usingsetTimeout
withthis.options.nextStringDelay || 0
.src/initializer.js
to includenextStringDelay
in theload
method for consistency with other timing options.The implementation ensures backward compatibility—if
nextStringDelay
is not specified, the behavior remains unchanged (immediate typing of the next string).Benefits
backDelay
andstartDelay
.setTimeout
, maintaining Typed.js’s lightweight performance profile.Example usage:
Issues