-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix(dropdown): use $animate for adding and removing classes #1644
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ angular.module('ui.bootstrap.dropdown', []) | |
}; | ||
}]) | ||
|
||
.controller('DropdownController', ['$scope', '$attrs', 'dropdownConfig', 'dropdownService', function($scope, $attrs, dropdownConfig, dropdownService) { | ||
.controller('DropdownController', ['$scope', '$attrs', 'dropdownConfig', 'dropdownService','$animate', function($scope, $attrs, dropdownConfig, dropdownService, $animate) { | ||
var self = this, openClass = dropdownConfig.openClass; | ||
|
||
this.init = function( element ) { | ||
|
@@ -54,7 +54,12 @@ angular.module('ui.bootstrap.dropdown', []) | |
}; | ||
|
||
$scope.$watch('isOpen', function( value ) { | ||
self.$element.toggleClass( openClass, value ); | ||
if (value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines can actually be shortened to:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $animate should have a promise, and the code after that should be inside the resolved function. Else the toggle function would be called before the dropdown is opened. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pull request is closed as I see (it was created looong time ago). |
||
$animate.addClass(self.$element, openClass); | ||
} | ||
else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The else should be in the same line as the closing braces of the if ( |
||
$animate.removeClass(self.$element, openClass); | ||
} | ||
|
||
if ( value ) { | ||
dropdownService.open( $scope ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space after the comma at
,'$anim
.