Skip to content

Instantly share code, notes, and snippets.

@TylerBarnes
Last active April 7, 2023 03:15
Show Gist options
  • Save TylerBarnes/82ccdb4046a32f178c538f2f8536663b to your computer and use it in GitHub Desktop.
Save TylerBarnes/82ccdb4046a32f178c538f2f8536663b to your computer and use it in GitHub Desktop.
GSAP ScrambleTextPlugin in React with Hooks
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