Scramble Text
Code
| 1 | // Takes a target ref + a nested params object; returns { rescramble, isReady }. |
| 2 | // No loop: each call decodes once. Call rescramble() to re-run (e.g. on shuffle). |
| 3 | const { rescramble, isReady } = useAnimeScramble({ |
| 4 | target: targetRef, |
| 5 | params: { |
| 6 | text: 'Hello World', |
| 7 | chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!<>-_\\/[]{}—=+*^?#', |
| 8 | cursor: true, |
| 9 | }, |
| 10 | autoplay: true, |
| 11 | }); |
| 12 | |
| 13 | <p ref={targetRef}>{text}</p> |
Decoding character scramble with a custom charset and optional cursor.
Live preview
Scramble TextDecoding character scramble
Scramble Text
initializing…
Props
| Name | Type | Default | Description |
|---|---|---|---|
| target | RefObject<T> | - | Element ref to scramble (input) |
| params.text | string | - | Final text to decode into |
| params.chars | string | - | Scramble character set |
| params.cursor | boolean | false | Show a blinking cursor |
| autoplay | boolean | false | Auto-start on mount |
| rescramble | function | - | Re-trigger the decode (returned) |
| isReady | boolean | - | True once the hook is initialized (returned) |