Jump to content
Search Community

Make only selected item animate

Demorus 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

One technical question. I have more than 3 .ss classes. How exactly do I make it so that only the selected .ss class of this timeline is animated?

 

 

var t= new TimelineMax({paused:true});

t.to('.ss', 4,  {rotation: 360, ease:Bounce.easeOut})
t.reverse();

$('.ss').click(function() {;
    t.reversed() ? t.play() : t.reverse();
});

 

I would appreciate some insight. I know that  "each()" does the job but how exactly to implement it in this context?

Link to comment
Share on other sites

You can use the event that gets passed by default inside the click handler

$(".ss").click(function(e){
  var selectedItem = $(e.currentTarget);
  t.to(selectedItem, 4, {rotation: 360, ease:Bounce.easeOut});
  t.play();
});

Mind that reverse is applied to the whole timeline effect, if you want individual tweens that can be reversed you might want to try TweenMax/Lite.

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