Jump to content
Search Community

animate only targeted element on scroll that doesn't have unique class or ID

Gremlin test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I have simple question but can't figure it out so I will just explain it without code it this is ok.

 

I'm calling a function when specific element comes into viewport. Let say that element has class button with opacity: 0.

Function tween it from opacity 0 to 1. After that all elements with with the class button have opacity 1. But I want that only button that is in viewport has opacity 1 and all others are still on 0. When second button comes into viewport he turns from 0 to 1 and so on.

Trick is that I don't want to set unique classes or ID's to every button. 

Is there a way to do it, or can you point me in the right direction?

 

thank you guys

    

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

We try to keep our support focused on the GreenSock API. 

From what you are describing it sounds like you already know how to detect when an element is in the viewport. When you run your detection script I would guess you could use a loop to loop through every element with a class of .button and see if it is in the viewport, if so, run a tween on it. 

Again, without seeing a demo its hard to really know what you are doing or what to suggest. 

 

 

 

 

 

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