Home > Back-end >  Package typewriter-effect changeDelay method doesn't work
Package typewriter-effect changeDelay method doesn't work

Time:06-05

In my React project I'm using Typewriter package.

It has method changeDelay, that doesn't actually work.

Here is an example number 1:

<Typewriter
  onInit={(typewriter) => {
    typewriter.typeString('Some text').changeDelay(1).start();
  }}
/>

In this case it should print text permanently, but it doesn't.

Here is example number 2. It works fine, I can change delay.

<Typewriter
  options={{
    strings: ['Some .'],
    delay: 80,
    autoStart: true,
    loop: true
  }}
/>

So, I have 2 questions.

  1. For first example, is how I can actually change delay speed?

OR

  1. For second example, is how I can prevent it from deleting text? (removing autoStart or/and loop doesn't work)

CodePudding user response:

For the first the case, you can use prop options in order to change the delay:

import React from 'react';
import Typewriter from 'typewriter-effect';
import './style.css';

export default function App() {
  return (
    <Typewriter
      onInit={(typewriter) => {
        typewriter.typeString('Some text').changeDelay(1).start();
      }}
      options={{
        delay: 100,
      }}
    />
  );
}

https://stackblitz.com/edit/react?file=src/App.js

  • Related