Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngShowHide): stop ngShow and ngHide applying animations incorrectly #4479

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ng/directive/ngShowHide.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@
*/
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');
var watchHasNeverFired = true;
scope.$watch(attr.ngShow, function ngShowWatchAction(value, oldValue){
if (watchHasNeverFired || (toBoolean(value) !== toBoolean(oldValue))) {
watchHasNeverFired = false;
$animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
}
});
};
}];
Expand Down Expand Up @@ -297,8 +301,11 @@ var ngShowDirective = ['$animate', function($animate) {
*/
var ngHideDirective = ['$animate', function($animate) {
return function(scope, element, attr) {
scope.$watch(attr.ngHide, function ngHideWatchAction(value){
$animate[toBoolean(value) ? 'addClass' : 'removeClass'](element, 'ng-hide');
var watchHasNeverFired = true;
scope.$watch(attr.ngHide, function ngHideWatchAction(value, oldValue){
if (watchHasNeverFired || (toBoolean(value) !== toBoolean(oldValue))) {
$animate[toBoolean(value) ? 'addClass' : 'removeClass'](element, 'ng-hide');
}
});
};
}];