Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-random-reveal

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-random-reveal

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

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
234
increased by50%
Maintainers
0
Weekly downloads
 
Created
Source

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

Text DemoEmoji DemoWords DemoReact Native
Edit cslqw Edit kp7ly Edit 8rr2w Expo Snack

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 NameTypeDefaultDescription
isPlayingbooleanrequiredPlay and pause animation.
charactersstring | ReactNode[]requiredCharacters to reveal in the end of the duration. These could be letters, numbers, emojis, words or components
durationnumberrequiredTotal animation duration in seconds. The duration includes the overall time random characters are shown plus the time for revealing the characters
updateIntervalnumber0.065Update interval in seconds. Determines how often the characters will change. When set to 0 the value will update on each key frame
revealDurationnumber0.6The 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'linearThe easing function used to reveal characters during the reveal duration
characterSetReactNode[]English alphabet: ['a', 'b', 'c', ... 'z']Characters that will be used during the random characters run
ignoreCharacterSetstring[]-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.

Keywords

FAQs

Package last updated on 17 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc