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-text-swap-animation

v1.4.0

Published

A React component to use CSS animations to swap letters in 2 words. The text is animated in position after calculating initial and final positions of each letter. Words which are anagrams will animate well, but you can use any words or phrases.

Downloads

6

Readme

React Text Swap Animation

A React component to use CSS animations to swap letters in 2 words.

The text is animated in position after calculating initial and final positions of each letter. Words which are anagrams will animate well, but you can use any words or phrases.

Install

yarn add react-text-swap-animation

or

npm install react-text-swap-animation

Demo

DEMO

CodeSandbox

Usage

import React from 'react';
import TextSwap from 'react-text-swap-animation';

export default function MyComponent() {
    return (
        <TextSwap words={['Text Swap Animation', 'Antitoxin Swamp Tea']} />
    );
}

To control the animation speed and timing, you can pass an object of animationOptions.

<TextSwap animationOptions={{
    randomStartMin: 0,
    randomStartMax: 0,
    randomReverseMin: 6000,
    randomReverseMax: 6000,
    loopAnimation: 20000,
    waitToStart: 5000,
    transitionDuration: 2000,
    timingFunction: 'ease-in-out',
}} />

If you are using an embedded font and need to wait for it to load before animating, then you should specify the fontToObserve property with the font family name.

<TextSwap fontToObserve="Open Sans" />
<TextSwap fontToObserve="Roboto" />

API

Props

| Prop | Type | Default | Description | | :----------------- | :----- |:-------------------------------------------------| :------------------------------------------------------ | | words | array | ['Text Swap Animation', 'Antitoxin Swamp Tea'] | An array containing exactly 2 words which are an anagram of each other. | | animationOptions | object | AnimationOptions | Timing options for when to start, how fast to animate forwards, backwards, and when to loop (optional). | | fontToObserve | string | | The name of an embedded font to wait until loaded. If not specified, animation will loaded immediately (optional). |

AnimationOptions

All time values are in # of milliseconds. The randomness allows a nice jumble effect. You can use any values you want to create some fascinating animations.

| Property | Type | Default | Description | | :------------------- | :----- | :------------ |:--------------------------------------------------------------------------------------------------------------------------------------| | randomStartMin | number | 0 | The minimum amount of time to randomly wait before starting to animate each letter. | | randomStartMax | number | 3000 | The maximum amount of time to randomly wait before starting to animate each letter. Should be >= randomStartMin. | | randomReverseMin | number | 6000 | The minimum amount of time to randomly wait before starting to animate each letter in reverse. | | randomReverseMax | number | 9000 | The maximum amount of time to randomly wait before starting to animate each letter in reverse. Should be >= randomReverseMin. | | loopAnimation | number | 12000 | The amount of time to wait before starting the next full loop of the animation. Should be >= randomReverseMax + transitionDuration. | | waitToStart | number | 0 | The amount of time to wait before beginning the animation on start up the first time. | | transitionDuration | number | 1000 | How long should it take for a letter to move to its next position. Should be <= randomReverseMin - randomStartMax. | | timingFunction | string | ease-in-out | What timing function should be used for the animation. |

Run Locally

To run demo locally:

  • yarn
  • yarn start

and a browser will open to the demo.

If you receive Invalid hook call errors because you are linking this module, you may need to point this library's React to your app's installed React so there is only one copy.

npm link ../my-app/node_modules/react
npm link ../my-app/node_modules/react-dom

Future Ideas

  • Supply different animation easing. Done!

License

WTFPL