Jump to content
Search Community

GSAP Array index i Element Hover Animation

AkhilRaja test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

I want to create a hover animation when I move my mouse on Slide 1, Slide 2, Slide 3,... etc will animate Slide A, Slide B, Slide C,... etc

I successfully created hover animation when I move my mouse on Slide A, Slide B, Slide C,... etc to animate the target element but can not create this animation work for Slide 1, Slide 2, Slide 3,... etc because these elements have two different parent element so I can not make it work.

I hope anyone can figure this out and help me thank you.

See the Pen KKmeZBw?editors=1000 by AkhilRaja (@AkhilRaja) on CodePen

Link to comment
Share on other sites

  • Solution

Just create an array for both sets of slides. Note that IDs have to be unique. So give your first 5 slides a certain class name, and so on with your second set.

let slides1 = gsap.utils.toArray(".slide-1");
let slides2 = gsap.utils.toArray(".slide-2");

slides1.forEach((el, i) => {
  
  // here's the matching one
  let slide2 = slides[i];
});

 

  • Like 4
  • Thanks 1
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...