Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have initial text ready #20

Closed
kevinlu1248 opened this issue Mar 22, 2023 · 5 comments
Closed

Have initial text ready #20

kevinlu1248 opened this issue Mar 22, 2023 · 5 comments

Comments

@kevinlu1248
Copy link

Hello,

Awesome package btw. I was wondering if there's a way of having initial text there, instead of initially having nothing and typing it out the first time.

@maxeth
Copy link
Owner

maxeth commented Mar 22, 2023

Hi, since the default wrapper for the animation is a <span>, you could just do something like this:

<span style={{ fontSize: '2em' }}>
      <span>We produce food for</span>{' '} // <--- will be pre-typed
      <TypeAnimation
        sequence={[
          'Mice',
          1000,
          'Hamsters',
          1000,
          'Guinea Pigs',
          1000,
          'Chinchillas',
          1000,
        ]}
        repeat={Infinity}
      />
</span>

But in that case, you couldn't animate that pre-typed string later in the animation sequence.

@kevinlu1248
Copy link
Author

Oh I meant like it is "We produce food for Mice" initially and "Mice" gets replaced by "Hamsters", etc.

@maxeth
Copy link
Owner

maxeth commented Mar 22, 2023

I see, so something like

    <TypeAnimation
       preRenderFirstString={true}
        sequence={[
          'A'
          1000,
          'B',
          1000,
          'C',
          1000
        ]}
        repeat={Infinity}
      />

Results in: 'A' (pre-rendered), 1s delay, 'B', 1s delay, 'C', 1s delay, 'A', ...

Sounds like a good feature, especially for SEO if you use server-side rendering. It's not possible yet but I'll add it in the following days.

@asp3
Copy link

asp3 commented Apr 23, 2023

hey! checking in on the preRenderedFirstString prop @maxeth

@maxeth
Copy link
Owner

maxeth commented Jun 10, 2023

hey! checking in on the preRenderedFirstString prop @maxeth

Added in version 3.1.0 https://react-type-animation.netlify.app/examples#initially-pre-rendered

@maxeth maxeth closed this as completed Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants