0.0.6 • Published 3 years ago

@a7sc11u/scramble v0.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Scramble

A scramble text UI component for react.

The animation maintains an internal ticking clock, that runs up to 60 times per second, or once per animation frame. The animation starts from the beginning of the text, and scrambles until the end of the input, given a set of parameters that allow you to control how many characters are added and over how many ticks, and how many times each character is randomized.

Live demo at https://scramble.vercel.app/

Props

Propertytypedefaultdescription
asstring-polymorphic tag
playbooleantruestart/stop animation
textstring-text to scramble.
speednumber0.40-1 range that determines the ticking speed. 1 means 1 tick per frame
scramblenumber8how many times each character will randomize
stepnumber1how many characters are added to the scramble on each tick
stepIntervalnumber1how many ticks it requires to increment the step index
seednumber3adds random characters to the scramble, ahead of the ticking loop
seedIntervalnumber10ticks required to seed more random characters
onCompletefunction-callback invoked on completion

Installation

  yarn add @a7sc11u/scramble
  //or
  npm install @a7sc11u/scramble

Usage

import { TextScramble } from '@a7sc11u/scramble';

export const App = () => {

  const elRef = React.useRef<HTMLDivElement>(null);

  const handleComplete = () => {
    console.log('scramble is done');
  }

  return (
    <TextScramble 
      ref={elRef}
      as="div"
      play={true}
      speed={0.4}
      scramble={8}
      step={1}
      stepInterval={1}
      seed={3}
      seedInterval={10}
      onComplete={handleComplete}
      text="Fugiat ullamco non magna dolor excepteur." 
    />
  );
};
0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago