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-random-reveal

v2.0.1

Published

React component/hook to add a little thrill before revealing the truth via random character animation

Downloads

808

Readme

React Random Reveal

npm GitHub Workflow Status Codecov npm bundle size

React/React Native component and hook to add a little thrill before revealing the truth. This effect is achieved via a character animation that shows random characters before revealing the text you want to emphasize. The library provides full control over the reveal run: its duration and easing can be freely adjusted.

📜 Animate random letters, numbers, emojis, words or components
🏆 Performance optimized with single requestAnimationFrame loop to animate the characters
📱 React Native support for iOS and Android

Installation

yarn add react-random-reveal

Demos

Basic usage

As a component:

import { RandomReveal } from 'react-random-reveal'

const AddSuspenseComponent = () => (
  <RandomReveal isPlaying duration={2} characters="hello world" />
)

As a hook:

import { useRandomReveal } from 'react-random-reveal'

const AddSuspenseComponent = () => {
  const characters = useRandomReveal({
    isPlaying: true,
    duration: 2,
    characters: 'hello world',
  })

  return characters
}

Props

| Prop Name | Type | Default | Description | | ------------------ | ------------------------------------------------------ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | isPlaying | boolean | required | Play and pause animation. | | characters | string | ReactNode[] | required | Characters to reveal in the end of the duration. These could be letters, numbers, emojis, words or components | | duration | number | required | Total animation duration in seconds. The duration includes the overall time random characters are shown plus the time for revealing the characters | | updateInterval | number | 0.065 | Update interval in seconds. Determines how often the characters will change. When set to 0 the value will update on each key frame | | revealDuration | number | 0.6 | The duration to reveal all characters is represented as a fraction of the total duration. This is a number between 0 and 1. When set to 0, all characters will be revealed in the end of the duration at once. When set to 1, characters will start revealing from the beginning of the duration | | revealEasing | 'linear' | 'easeInQuad' | 'easeOutQuad' | 'random' | linear | The easing function used to reveal characters during the reveal duration | | characterSet | ReactNode[] | English alphabet: ['a', 'b', 'c', ... 'z'] | Characters that will be used during the random characters run | | ignoreCharacterSet | string[] | - | Characters that won't be animated and will always be revealed. Can be used to ignore animating space or any special characters. | | onComplete | () => void | { shouldRepeat: boolean, delay: number } | - | The callback is fired when the duration is reached. It can be used to restart the animation by returning an object with the following params: shouldRepeat - indicates if the loop should start over; delay - delay before looping again in seconds |

Browser support

We support all modern browsers targeting es6. Internet Explorer (IE) is not longer supported.