Jump to content
Search Community

Bootstrap dropdowns

dexterca 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

I'm new to gsap and I'm trying to animate Bootstrap dropdowns, but my results have been buggy in all browsers.

 

The tweens seem to get stuck or stop. Sometimes it works perfectly, then others not. I've also noticed double clicking seems to break the tweens.

 

Example of when the tweens break
 

post-50630-0-39113700-1486999860_thumb.png

 

See the Pen dNwLwP by dexterca (@dexterca) on CodePen

Link to comment
Share on other sites

Hi dexterca :)

 

Welcome to the forum.

 

I'd recommend creating your dropdown timeline in advance and play/reverse it on click. As you have it now, you're creating a new timeline on each click and that can result in tweens getting overwritten and breaking the animation. (which you've seen) Please try this: 

var tl = new TimelineMax({paused:true, reversed:true});
tl.from('.dropdown-menu', .25, {height: 0, ease: Power2.easeOut, opacity: 0})
tl.staggerFrom('.dropdown-menu > li', .2, {y: -20, opacity: 0}, .015);

$('#dropdown-toggle-1').on('click', function () {
   tl.reversed() ? tl.play() : tl.reverse() 
});

I don't know anything about Bootstrap, but I see a whole bunch of transforms in the CSS. I can't be sure the Bootstrap CSS animations won't conflict with GSAP animations, but the above code should get you started.

 

Happy tweening.

:)

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