-
-
Save mfrancois3k/68183246b19d6cec50a337eafdea9df2 to your computer and use it in GitHub Desktop.
GSAP ScrambleTextPlugin in React with Hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useRef, useEffect } from "react"; | |
| import TweenLite from "gsap"; | |
| import "../../libs/gsap/ScrambleTextPlugin"; | |
| export default ({ children }) => { | |
| if (typeof window === "undefined") return children; | |
| const text = useRef(null); | |
| useEffect(() => { | |
| TweenLite.to(text.current, 1.2, { | |
| scrambleText: { | |
| text: children, | |
| chars: children, | |
| revealDelay: 1, | |
| speed: 0.5 | |
| } | |
| }); | |
| }); | |
| return <span ref={text}>{children}</span>; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment