Is there a way to calculate the whole time which Typed.js takes?

100 Views Asked by At

I will calculate the whole time which Typed.js takes to type custom sentences. I will start a soundtrack with some negative delay (depends on that soundtrack) at the end of typing finish time.

combination of sentence and soundtracs

All sentence typing takes n milliseconds; I want to start the soundtrack (n - delay) milliseconds from the beginning of the typing process.

This n can be calculated from fadeOutDelay, startDelay, typeSpeed, but the diffing which Typed.js uses not to remove the previous sentence. Involvement of diffing algorithm in n calculation looks a bad practice for me, and I want to keep that diffing algorithm  .

Here is packages I use:

 "dependencies": {
    "howler": "2.2.1",
    "typed.js": "2.0.11"
  },

All other solutions are welcomed.

edited

I added a simple demo with hard-coded timing for some sound.

  1. sound will no be played in this demo :)
  2. All of the stuff and timing must be dynamically calculated.
0

There are 0 best solutions below