Jump to content
Search Community

Passing $(this) into a Timeline

ryanf 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

Hello, 

 

Is it possible to pass $(this) into a timeline so that I can access $(this) as well as the data attributes of an object?  

 

In the example pen I'd like to pass data attribute values from buttons into the timeline, ultimately to fade between two images - only after they have each fully loaded.  

 

Thanks.  

 

See the Pen GjkAyW by rfenik (@rfenik) on CodePen

Link to comment
Share on other sites

Thanks for the demo. I don't think things are going to work the way you are hoping (unless I'm misunderstanding).

 

When a timeline is built it needs to know what the targets and values of all the tweens will be. I get the impression you hope to build one timeline and then have it play at different times with different targets and values as the value of $(this) changes based on what button is clicked.

 

I think for this situation you want to create a function that you pass $(this) into and then that function will create a new timeline with all the right values pertaining to the new image you want to display.

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