Jump to content
Search Community

Switch Array of SVG Component

tatanka test
Moderator Tag

Go to solution Solved by tatanka,

Recommended Posts

Hello everyone, I want to make some animations just like here: https://gsap.com/community/forums/topic/32504-loop-through-an-array-of-text-and-display-on-screen/?do=findComment&comment=175412&_rid=151858 but using Svg components. I basicaly want to switch between svg components instead of texts. 

My current work is here:  https://stackblitz.com/edit/stackblitz-starters-egrwn8?file=components%2FLogo%2Findex.tsx

 

Any help really appreciated!

Link to comment
Share on other sites

  • Solution

I found this solution maybe it helps anybody 

 

const array = ['svg-a', 'svg-b', 'svg-c'];

  useGSAP(
    () => {
      tl.current = gsap.timeline({ delay: 1.5 });
      array.forEach((item, index) => {
        tl.current
          .to(`.${array[index - 1]}`, {
            display: "none",
            duration: 0.1,
          })
          .to(`.${item}`, {
            display: "block",
            duration: 0.1,
          });
      });
    },
    { scope: container },
  );

 

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...