Giter Club home page Giter Club logo

react-typing-effect's Introduction

React Typing Effect

This is a UI component built completely in React that simulates typing effect, eraser effect and a blinking cursor.

Demo

Screenshot 1

Getting Started

$ npm install --save react-typing-effect

ReactTypingEffect is the main component.

Example Usage:

import React from 'react';
import ReactTypingEffect from 'react-typing-effect';

const ReactTypingEffectDemo = () => {
  return (
    <>
      <ReactTypingEffect
        text={["Hello.", "World!"]}
      />

      <br />

      <ReactTypingEffect
        text={["Hello.", "World!!!"]}
        cursorRenderer={cursor => <h1>{cursor}</h1>}
        displayTextRenderer={(text, i) => {
          return (
            <h1>
              {text.split('').map((char, i) => {
                const key = `${i}`;
                return (
                  <span
                    key={key}
                    style={i%2 === 0 ? { color: 'magenta'} : {}}
                  >{char}</span>
                );
              })}
            </h1>
          );
        }}        
      />
    </>
  );
};

Motivation

Inspired by this blog post http://burnmind.com/tutorials/how-to-create-a-typing-effect-an-eraser-effect-and-a-blinking-cursor-using-jquery

API

Required Props

  • text: That text that will be typed and erased. Can be either an array of strings or just a string.

Other Props

  • displayTextRenderer: func. (displayText: string, textIndex: number) => element If text propType is array, then textIndex will be the array index of the text, otherwise textIndex will be equal to 0.
  • staticText: String. Text that will just be static and cannot be typed or erased.
  • className: String
  • speed: Number. default 500ms. Typing speed.
  • eraseSpeed: Number. default 500ms. Erase speed.
  • eraseDelay: Number. default 5000ms. Time to wait before erasing the text.
  • typingDelay: Number. default 2500ms. Time to wait before starting to type.
  • cursor: String. Default: |
  • cursorClassName: String

react-typing-effect's People

Contributors

dependabot[bot] avatar farai-bws avatar jgebhardt avatar letsreactjs avatar maniart avatar michael-goss avatar sylchauf avatar xdabier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-typing-effect's Issues

Errors on 1.0.4

Hello @lamyfarai

I'm getting errors on 1.0.4:

* /home/lamyfarai/WorkBench/react-typing-effect/node_modules/react-transform-catch-errors/lib/index.js in ./node_modules/react-typing-effect/build/index.js, ./node_modules/react-typing-effect/build/Cursor.js
* /home/lamyfarai/WorkBench/react-typing-effect/node_modules/react-transform-hmr/lib/index.js in ./node_modules/react-typing-effect/build/index.js, ./node_modules/react-typing-effect/build/Cursor.js
* /home/lamyfarai/WorkBench/react-typing-effect/node_modules/redbox-react/lib/index.js in ./node_modules/react-typing-effect/build/index.js, ./node_modules/react-typing-effect/build/Cursor.js

To install them, you can run: npm install --save /home/lamyfarai/WorkBench/react-typing-effect/node_modules/react-transform-catch-errors/lib/index.js /home/lamyfarai/WorkBench/react-typing-effect/node_modules/react-transform-hmr/lib/index.js /home/lamyfarai/WorkBench/react-typing-effect/node_modules/redbox-react/lib/index.js

It's like there where hardcoded paths on ./node_modules/react-typing-effect/build/index.js

Strange...

Anyway, i've fixed downgrading to 1.0.3

State update warning

I am getting the below warning sometimes. not consistent. This happens when I change pages via react-router.

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in TypingEffect (at Hero/index.jsx:14)

This is line:14

<ReactTypingEffect
                  text={musicTypes} 
                  speed={100}
                  eraseDelay={1000}
                  className="ml-2 type-text text-red"
                  />

ReferenceError: window is not defined

Hi,

Thanks for working on this. The source you've pushed to npm invokes window even though its not required and also not in the original source code. This prevents this library from being used in server-side rendered react projects like Next.js

You might want to build the source with Webpack instead of babel directly.

Workaround
Vendorize src/* into your local project. Use the library with a relative import.

HTML tags treated as string

<ReactTypingEffect
                text={['Propelling Startups to <span style="color: #136bc3;">Stardom</span> ', "World!"]}
                speed = '3'
              />

This results in pure text instead of styles being applied to the text.

Add option to set delay between typing text

I was wondering if there is an option for setting delay before typing the text? I could only set the eraseSpeed and typeSpeed but not the delay between typing each text. Currently, I feel the delay is high and I would like to lower it.

cursorClassName not working

cursorClassName prop is not working.

Shouldn't this

 const classes = cx(cursorClassName, 'lfm__typing_effect_cursor');
    return (
      <span style={getStyles(display)}>
        {cursor || "|"}
      </span>
    );

be

 const classes = cx(cursorClassName, 'lfm__typing_effect_cursor');
    return (
      <span className={classes} style={getStyles(display)}>
        {cursor || "|"}
      </span>
    );

Line:

<span style={getStyles(display)}>

window is not defined

With version 2.0.4 installed through yarn add it gives error.

Error: window is not defined

error_yarn_react_typing_effect

I'm using:

"next": "10.0.3",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-typing-effect": "^2.0.4",

I know that the version that is in the master branch solves this error, I open this issue because I need this solution to be available in the package managers. Is there an estimated date for the new release?

Thank you very much for the work done in this library ๐Ÿ–ค

Feature Request: no-repeat

Not sure how to leave a feature request so apologies if this isn't the right way to do this, is there a way to only have it loop through the array of words once?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.