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-animated-text-content

v1.0.1

Published

Animate your jsx/html text using React component

Downloads

1,188

Readme

react-animated-text-content

npm npm

A component to animate your text in React! Use predefined animation type or compose your own one.

Demo

Install

  npm install --save react-animated-text-content

Note

Component has animate on scroll functionality built in (whith Intersection Observer api) so you don't have to use 3rd party libs to achieve this. If you want to find out more about Intersection Observer check mdn page about that topic here.

Important

Be careful with using this library and don't overdo with it. To achieve text animation like this way, the big chunck of HTML must be rendered and every text fragment has separated animation properties depending on props passed. This could cause serious performance leaks (especially in case of chars type) but it may not. Just use it with cool head and don't use long texts to animate!

Using

import AnimatedText from 'react-animated-text-content';

<AnimatedText
  type="words" // animate words or chars
  animation={{
    x: '200px',
    y: '-20px',
    scale: 1.1,
    ease: 'ease-in-out',
  }}
  animationType="float"
  interval={0.06}
  duration={0.8}
  tag="p"
  className="animated-paragraph"
  includeWhiteSpaces
  threshold={0.1}
  rootMargin="20%"
>
  Content to animate
</AnimatedText>;

The AnimatedText component render way is fully customizable. If you want, you can use predefined animation or compose your own one. In order to check and test predefined animation types, visit demo site. You can use animation generator there as well and generate code to paste in.

  • define own animation object and pass it as props,
  • if you use animationType prop, the animation prop is not valid anymore (no effect),
  • you can oberwrite default duration and interval values (from animationType as well) by defining pure props. These props always has higher priority. If no specified, the fallback with default value is used

props

All props are optional.

| name | type | default | description | | ---------------------- | --------------------------------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | type | 'words' | 'chars' | specify animation render way. Depending on type the HTML of component is drastically different | | animation | {x: string, y: string, scale: number, ease: string} | { y: '-30px' } | define animation from state with optional properties like: x, y, ease, scale | | animationType | string | - | use predefined animation (check currently available ones at demo page) | | children | ReactText | '' | the most important prop. Currently as ReactText type so no addiditional elements are allowed like <br />. If so, the error will be catched | | interval | number | 0.04 | pretty same as animation prop object property. Use this version of props to overwrite default value from animationType or animation object. s (seconds) unit. Says to the component how quickly next fragments of the text should be animated | | duration | number | 0.4 | pretty same as animation prop object property. Use this version of props to overwrite default value from animationType or animation object. s (seconds) unit. Says to the component how long will animation be performing in case of one fragment | | tag | string | 'div' | specify custom HTML tag you want to render as you animated text parent. Be aware of that some of tags could break animation behavior or event stop runtime so use it carefully | | className | string | - | define own class for component | | includeWhiteSpaces | boolean | false | white spaces could be rendered in separated tags or as blank chars. Change it only if you must. When set to true, performance goes down | | threshold | number | 0 | value for Intersection Observer. Find out more here docs. Otherwise, leave it default | | rootMargin | string | 0 | value for Intersection Observer. Find out more here docs. Otherwise, leave it default. px and % units are allowed | | {...props} | - | - | all props like style, aria-, id are allowed |

LICENSE

MIT