Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Andy1708

Scrolltrigger greensock demo question

Recommended Posts

I have one question with this greensock's pen (link).

why using "gsap.utils.toArray(".comparisonSection").forEach(section => {}...." if you have only one section ?

it could perfectly work without and with the trigger set to : .comparisonSection

thanks for your answer

Andy

See the Pen oNjgEjm by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

25 minutes ago, Andy1708 said:

why using "gsap.utils.toArray(".comparisonSection").forEach(section => {}...." if you have only one section ?

it could perfectly work without and with the trigger set to : .comparisonSection

thanks for your answer

Hey Andy. I created it in this way in case someone added more similar sections later on :) It doesn't add much to the code to support multiple instances and it's good to show how it could be done (even before people ask). Not having to modify the code later if you wanted to add support for multiple instances is also a plus.

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