Jump to content
Search Community

Finding and animating clicked childs name within parent class

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

For some reason it works the first time but the second item clicked staggers away with the rest while the first item clicked remains visible. It is pretty weird

 

 

my javascript code:

  var children = $('.icons').children();
  var icons = new TimelineLite({paused:true});
    
children.click(function(event) {
      var siblings = $(this).siblings()
      span = $(this).find("span").first()
      content = $(this).find("div")
      h1 = content.find("h2")
      li = content.find("li")
      clicks =  $(this).data('clicks');
      icons.staggerTo(siblings, 1.3, {left:"-150%", ease:Back.easeIn}, 0.1)
      
  if (clicks) {
     TweenMax.to(span, 1, {opacity:0, ease:Power2.easeInOut})
     TweenMax.to(content, 1, {display:"none", delay:1.5, ease:Power2.easeInOut})
     TweenMax.to(h1, 1, {opacity:0, ease:Power2.easeInOut})
     TweenMax.to(li, 1, {opacity:0, ease:Power2.easeInOut})
     setTimeout(function(){ icons.reverse(); }, 500);
  } else {
     TweenMax.to(span, 1, {opacity:0, delay:1.5, ease:Power2.easeInOut})
     TweenMax.to(content, 0, {display:"block", delay:1.5, ease:Power2.easeInOut})
     TweenMax.to(h1, 1, {opacity:1, delay:1.5, ease:Power2.easeInOut})
     TweenMax.to(li, 1, {opacity:1, delay:1.5, ease:Power2.easeInOut})
     TweenMax.to(this, 1, {width:"46%", top:"2em", left:"-2%", delay:1.5, ease:Power2.easeInOut})
     icons.play()
  }
  $(this).data("clicks", !clicks);
});
 

Link to comment
Share on other sites

Hi,

 

This seems like much more of a jQuery question related to finding parents and sibilings than anything to do with GSAP.

 

However, I took your code and very roughly put together an animation that I think works for you.

The HTML and css is very rough.

 

I just wanted to show that you could click on a red box (less code than your svgs) to hide the icons you didn't click on and then animate things related to the red box you did click on.

 

look here:

 

http://codepen.io/GreenSock/pen/OPxMMx/

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