This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ngShowDirective adds the ng-hide-remove class when the element is already shown #4401
Closed
Description
ngShowDirective watches attr.ngShow, and adds ng-hide-remove class even when the attr.ngShow value "changes" from true to true (or from false to false).
Animations should only be applied if the actual value of ng-hide has changed:
The function on line 146 of https://github.com/angular/angular.js/blob/master/src/ng/directive/ngShowHide.js
var ngShowDirective = ['$animate', function($animate) {
return function(scope, element, attr) {
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
$animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
});
};
}];
should become
var ngShowDirective = ['$animate', function($animate) {
return function(scope, element, attr) {
scope.$watch(attr.ngShow, function ngShowWatchAction(value, oldValue){
if ( toBoolean(value) !== toBoolean(oldValue) ) {
$animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
}
});
};
}];
and similar with ngHideDirective on line 298