Jump to content
Search Community

Text Animation Effect

Lord test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

  • Lord changed the title to Text Animation Effect
5 hours ago, Rodrigo said:

Hi,

 

What exactly is not working in the link you posted? More precisely what is the effect you are looking for?

 

Happy Tweening!

by reference, everything works as expected, but in my application the same code does not delete 2-3 letters without any changes.
What could be the reason?

And how to make this effect erase all letters in words except the last? That is, when he begins to erase the word, he does not erase the last letter, but smoothly changes its transparency and substitutes the first letter of the next word and then begins to write further the next word

 

hope i explained clearly

thanks

Link to comment
Share on other sites

Hi,

 

Maybe something like this:

const texts = ["Lorem", "Ipsum", "Dolor", "Amit", "Excepteur"];

export default function App() {
  const sloganWrapperRef = useRef(null);

  useLayoutEffect(() => {
    const ctx = gsap.context((self) => {
      const updatedTexts = [...texts];
      updatedTexts.shift();
      const tl = gsap.timeline();
      updatedTexts.forEach((text, i) => {
        tl
        .to("p span", {
          text: "",
          speed: 1
        }, "+=1")
        .to("p span", {
            speed: 1,
            text: text,
          }
        );
      });
    }, sloganWrapperRef);

    return () => ctx.revert();
  }, []);

  return (
    <div className="sloganWrapper" ref={sloganWrapperRef}>
      <p>
        <span>{texts[0]}</span> Smarter
      </p>
    </div>
  );
}

Here is a fork of your example:

https://codesandbox.io/s/bitter-lake-x9y3xp?file=/src/App.js

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...