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

@pr0gramm/react-text-loop

v0.1.3

Published

Create an animated loop of a list of text for your headings

Downloads

267

Readme

@pr0gramm/react-text-loop

text-loop2

An animated loop of text nodes for your headings. Uses react-motion for the transition so it handles super fast animations and spring params. It's 6x smaller, maintained, but uses the same API as the original react-text-loop. Used by ant-design! Thanks to @braposo and samarmohan for creating the original!

npm version npm downloads MIT License PRs Welcome


Installation

Some commands for you to copy:

npm i @pr0gramm/react-text-loop
yarn add @pr0gramm/react-text-loop
bun add @pr0gramm/react-text-loop

How to use

You can also run the examples by cloning the repo and running npm start.

Usage

import { TextLoop } from "@pr0gramm/react-text-loop";

const App = () => {
  return (
    <h2>
      <TextLoop>
        <span>First item</span>
        <a href="/">Second item</a>
        <p style={{ color: "red" }}>Third item</p>
      </TextLoop>{" "}
      and something else.
    </h2>
  );
};

Props

| Prop | Type | Default | Definition | | -------------- | --------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | interval | number | array | 3000 | The frequency (in ms) that the words change. Can also pass an array if you want a different interval per children | | delay | number | 0 | A delay (in ms) for the animation to start. This allows to use multiple instances to create a staggered animation effect for example. | | adjustingSpeed | number | 150 | The speed that the container around each word adjusts to the next one (in ms). Usually you don't need to change this. | | fade | boolean | true | Enable or disable the fade animation on enter and leave | | mask | boolean | false | Mask the animation around the bounding box of the animated content | | noWrap | boolean | true | Disable whitepace: nowrap style for each element. This is used by default so we can always get the right width of the element but can have issues sometimes. | | springConfig | object | { stiffness: 340, damping: 30 } | Configuration for react-motion spring | | className | string | | Any additional CSS classes you might want to use to style the image | | children | node | | The words you want to loop (required) |

Caveats

Because <TextLoop> loops through its children nodes, only root-level nodes will be considered so doing something like:

<TextLoop>
  <div>
    <span>First item</span>
    <span>Second item</span>
  </div>
  <div>Third item</div>
</TextLoop>

will make first and second item to be treated as one and animate together.

You can also just send a normal array as children prop if you don't need any individual styling for each node.

<TextLoop
  children={[
    "Trade faster",
    "Increase sales",
    "Stock winners",
    "Price perfectly",
  ]}
/>

Examples

Fast transition

text-loop-fast-small

<TextLoop interval={100}>...</TextLoop>

Wobbly animation

text-loop-bouncy

<TextLoop springConfig={{ stiffness: 180, damping: 8 }}>...</TextLoop>

For many other examples, please have a look at the CodeSandbox playground.

Contributing

Please follow our contributing guidelines.

License

MIT