Jump to content
Search Community

How to access element index when passing list of elements in ".to" or ".from" etc

sak test
Moderator Tag

Go to solution Solved by sak,

Recommended Posts

This code doesn't work as the 'index' variable is not defined, what is the best way to go about it?
 

timeline.from([...featureCards], {
      opacity: 0,
      y: 60 * Math.pow(-1, index),
      ease: "power3.out",
      duration: 0.7,
      stagger: 0.3,
    });
Link to comment
Share on other sites

  • Solution

My bad, figured it out from the docs - 

timeline.from([...featureCards], {
      opacity: 0,
      y: (idx) => 60 * Math.pow(-1, idx),
      ease: "power3.out",
      duration: 0.7,
      stagger: 0.3,
    });
  • Like 1
  • Haha 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...