Jump to content


Reverse all sibling tweens on click on menu item

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


I'm trying to find how to reverse all sibling tweens when clicking on one of them and then play its tween.


Any Idea?


            $j('.menu_link_parent').each(function(index, el) {
                var $this = $j(this);
                var subMenu = $this.find('div.submenu');
                var timeLine = new TimelineMax ({
                    paused: true,
                    reversed: true,
                    align: 'sequence',
                var anim = 
                    timeLine.staggerFromTo( subMenu, 0.3, {
                        rotationX : 90,
                        autoAlpha : 0
                    }, {
                        rotationX : 0,
                        autoAlpha : 1,
                        onStart       : app.fn.common.makeVisible($j('.tw')),
                        onStartParams : $j('.tw'),
                    }, 0.3, '-=0.3' );
                $this.on('click', function(event) {
                   /* TODO : REVERSE ALL SIBLINGS FIRST */
                    anim.reversed() ? anim.play() : anim.reverse();


Link to comment
Share on other sites

Hi kayhan80,


Welcome to GreenSock Forums.


I´m not sure if I understood your case correctly.


My interpretation is like this CodePen: 


See the Pen qrgVve by mikeK (@mikeK) on CodePen


If that´s not a solution you expect it would be great if you provide a reduced CodePen showing your purpose.


Kind regards




  • Like 6
Link to comment
Share on other sites

Thanks @mikel


Your solution is great, and for more information about my problem, here is my code on pen:


I just want to tween back all played timelines while click on any parent menu which has a sub menu and tween its submenu to show.


See the Pen OgqgVo by kayhan80 (@kayhan80) on CodePen


Link to comment
Share on other sites

Hi kayhan80,


just for fun...


The click version:


See the Pen NgJmdN by mikeK (@mikeK) on CodePen


and - I would prefer - the mouseenter version:


See the Pen EXMJdd by mikeK (@mikeK) on CodePen


Happy tweening ...




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