npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-type-animation

v0.4.0

Published

React Native Type Animation is a component library that allows you to create engaging typewriter-style text animations in your React Native applications.

Downloads

633

Readme

Installation

npm install react-native-type-animation

Or, if you prefer yarn:

yarn add react-native-type-animation

Documentation

The docs can be found here: https://docs.benjamineruvieru.com/react-native-type-animation

Usage

import { TypeAnimation } from 'react-native-type-animation';

const MyComponent = () => {
  return (
    <TypeAnimation
      sequence={[
        { text: 'One' },
        { text: 'One Two' },
        {
          action: () => {
            console.log('Finished first two sequences');
          },
        },
        { text: 'One Two Three' },
        { text: 'One Two' },
        { text: 'One' },
      ]}
      loop
      style={{
        color: 'white',
        backgroundColor: 'green',
        fontSize: 30,
      }}
    />
  );
};

export default MyComponent;

Props

The following props allows you to configure the properties for the type animation component. It allows you to define an animation sequence, control the speed and behavior of the animation, and customize the appearance of the cursor.

| Prop | Required | Type | Default | Description | | ---------------------- | -------- | --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | | blinkSpeed | no | Number | 500 | The speed at which the cursor blinks (in milliseconds). | | cursor | no | Boolean | true | Whether to display the cursor. | | cursorStyle | no | TextStyle | | Additional styles for the cursor. | | delayBetweenSequence | no | Number | 100 | Delay between animation sequences (in milliseconds). | | direction | no | String | front | Specifies the direction in which to perform the typing/deleting animation. It accepts two possible values: 'front' and 'back'. | | initialDelay | no | Number | 0 | The delay before the animation begins (in milliseconds). | | loop | no | Boolean | false | Whether to loop the typing animation indefinitely. | | onCharTyped | no | Function | | Callback function triggered when a character is typed. | | onCharDeleted | no | Function | | Callback function triggered when a character is deleted. | | preRenderText | no | String | None | Specifies the initial text to display. | | repeat | no | Number | 1 | The number of times to repeat the sequence. | | sequence | yes | Array | | An array of objects defining the text to be typed and animation options. | | splitter | no | Function | | A function to split text into individual characters or chunks for typing. | | style | no | TextStyle | | Additional styles for the typewriter animation container. | | typeSpeed | no | Number | 100 | The speed at which characters are typed. | | deletionSpeed | no | Number | 100 | The speed at which characters are deleted. |

sequence Array

The sequence prop is an array of objects, where each object defines a part of the animation sequence. It can contain the following properties:

  • action: A function to execute as part of the sequence. This can be used as a callback to perform actions during the animation.

  • text: The text to display or type in the sequence.

  • delayBetweenSequence: The delay between the current sequence (in milliseconds) and the next. The default is 100, but you can specify a custom value for individual sequences.

  • deleteCount: The number of characters to delete before typing (backspacing).

  • deletionSpeed: The speed at which characters are deleted from this sequence (backspace speed, in milliseconds). The default is 100, but you can specify a custom value for individual sequences.

  • typeSpeed: The speed at which characters are typed in this sequence(typing speed, in milliseconds). The default is 100, but you can specify a custom value for individual sequences.

direction String

The direction prop specifies the direction in which to perform the typing/deleting animation. It accepts two possible values: 'front' and 'back'.

splitter Function

The splitter prop is a function that can be used to split text into individual characters or chunks for typing. This allows you to control how the text is broken down during the animation.

repeat Number

The repeat prop determines how many times the entire animation sequence should be repeated. The default is 1, meaning the sequence is played once.

loop Boolean

The loop prop, when set to true, causes the typing animation to loop indefinitely. If set to false (the default), the animation will play only once.

blinkSpeed Number

The blinkSpeed prop controls the speed at which the cursor blinks. The default is 500 milliseconds, but you can adjust this value as needed.

style TextStyle

The style prop allows you to provide additional styles for the typewriter animation container. You can customize the appearance of the entire animation component using this prop.

cursorStyle TextStyle

The cursorStyle prop is used to apply additional styles to the cursor element. This lets you customize the appearance of the cursor, such as its color and size.

cursor Boolean

The cursor prop determines whether the cursor is displayed during the animation. By default, it is set to true, but you can set it to false if you don't want to display the cursor.

onCharTyped Callback

This callback function is triggered each time a character is typed. It receives an object as an argument containing two properties:

  • character: The character that was just typed.
  • currentText: The current state of the text after the character has been typed.

onCharDeleted Callback

This callback function is triggered each time a character is deleted. It receives an object as an argument containing two properties:

  • character: The character that was just deleted.
  • currentText: The current state of the text after the character has been deleted.

Note: When using the sequence prop, you can define complex typing animations with different text, delays, and actions. Each object in the sequence array represents a step in the animation.

Example usage of TypeAnimationProps:

const animationProps = {
  sequence: [
    { text: 'Hello, ', typeSpeed: 100 },
    { text: 'World!', typeSpeed: 150, delayBetweenSequence: 500 },
  ],
  delayBetweenSequence: 200,
  repeat: 2,
  blinkSpeed: 400,
  cursorStyle: { color: 'red' },
};
const animationProps = {
  sequence: [
    { text: 'Hello World!', typeSpeed: 100 },
    { text: 'Hola World!', typeSpeed: 150, delayBetweenSequence: 500 },
  ],
  delayBetweenSequence: 200,
  loop: true,
  blinkSpeed: 400,
  cursorStyle: { color: 'red' },
  direction: 'back',
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT