I want to add animations to the opening and closing of a dropdown in my angular app. So far I can get open animations working on the dropdown, but nothing for close animations.
I took the navbar code straight from the bootstrap example and added it to my page with some minor modifications. The relevant part of the navbar is this:
<ul class="nav navbar-nav navbar-right">
<li ng-if="isAuthenticated()" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ authenticatedUser.displayName }} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li ng-if="menuItem.show()" ng-repeat="menuItem in menuItems" ng-class="{active: menuItem.active, disabled: menuItem.disabled}">
<a ui-sref="{{ menuItem.state }}({{ menuItem.stateParams }})">{{ menuItem.heading }}</a>
</li>
</ul>
</li>
</ul>
I'm also using angular bootstrap so the line:
<li ng-if="isAuthenticated()" class="dropdown">
triggers angular's own Dropdown directive.
I noticed by simply adding a class to the inner <ul class="dropdown-menu" ...> element I could get a nice open animation.
<ul class="dropdown-menu my-cool-opening-animation" role="menu">
2 questions:
- Is this the correct 'angular' way to add the animation?
- The animation works when the dropdown opens, but I can't get any animation when the dropdown closes, how do you do this?
This issue looks very similar to what I'm seeing and the fix for the issue seem to be very closely related to what I want. But I don't really understand how to apply it to get animations on the dropdown close.
As a side note, but possibly relevant is I'd like to use/am using the animate.css package as a base for my css animations.