Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Forked from TylerBarnes/ScrambleText.jsx
Created April 7, 2023 03:15
Show Gist options
  • Select an option

  • Save mfrancois3k/68183246b19d6cec50a337eafdea9df2 to your computer and use it in GitHub Desktop.

Select an option

Save mfrancois3k/68183246b19d6cec50a337eafdea9df2 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