From 8ed0d5b6aa2e29ebc8d2026cb04380ed3343baef Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Tue, 23 Jul 2013 23:02:15 -0400 Subject: chore($animate): replace show/hide with addClass/removeClass --- src/ng/animate.js | 10 ------- src/ng/directive/ngShowHide.js | 4 +-- src/ngAnimate/animate.js | 62 +----------------------------------------- 3 files changed, 3 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/ng/animate.js b/src/ng/animate.js index 7e515594..206a4b03 100644 --- a/src/ng/animate.js +++ b/src/ng/animate.js @@ -80,16 +80,6 @@ var $AnimateProvider = ['$provide', function($provide) { this.enter(element, parent, after, done); }, - show : function(element, done) { - element.removeClass('ng-hide'); - (done || noop)(); - }, - - hide : function(element, done) { - element.addClass('ng-hide'); - (done || noop)(); - }, - addClass : function(element, className, done) { className = isString(className) ? className : diff --git a/src/ng/directive/ngShowHide.js b/src/ng/directive/ngShowHide.js index bdbcf463..1bba11ef 100644 --- a/src/ng/directive/ngShowHide.js +++ b/src/ng/directive/ngShowHide.js @@ -100,7 +100,7 @@ var ngShowDirective = ['$animate', function($animate) { return function(scope, element, attr) { scope.$watch(attr.ngShow, function ngShowWatchAction(value){ - $animate[toBoolean(value) ? 'show' : 'hide'](element); + $animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide'); }); }; }]; @@ -204,7 +204,7 @@ 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) ? 'hide' : 'show'](element); + $animate[toBoolean(value) ? 'addClass' : 'removeClass'](element, 'ng-hide'); }); }; }]; diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index ab7a19b0..93ff9d8c 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -30,8 +30,8 @@ * | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave | * | {@link ng.directive:ngSwitch#animations ngSwitch} | enter and leave | * | {@link ng.directive:ngIf#animations ngIf} | enter and leave | - * | {@link ng.directive:ngShow#animations ngShow & ngHide} | show and hide | * | {@link ng.directive:ngShow#animations ngClass} | add and remove | + * | {@link ng.directive:ngShow#animations ngShow & ngHide} | add and remove (the ng-hide class value) | * * You can find out more information about animations upon visiting each directive page. * @@ -335,60 +335,6 @@ angular.module('ngAnimate', ['ng']) performAnimation('move', 'ng-move', element, null, null, done); }, - /** - * @ngdoc function - * @name ngAnimate.$animate#show - * @methodOf ngAnimate.$animate - * @function - * - * @description - * Reveals the element by removing the `ng-hide` class thus performing an animation in the process. During - * this animation the CSS classes present on the element will be: - * - *
- * .ng-hide //already on the element if hidden - * .ng-hide-remove - * .ng-hide-remove-active - *- * - * Once the animation is complete then all three CSS classes will be removed from the element. - * The done callback, if provided, will be also fired once the animation is complete. - * - * @param {jQuery/jqLite element} element the element that will be rendered visible or hidden - * @param {function()=} done callback function that will be called once the animation is complete - */ - show : function(element, done) { - performAnimation('show', 'ng-hide-remove', element, null, null, function() { - $delegate.show(element, done); - }); - }, - - /** - * @ngdoc function - * @name ngAnimate.$animate#hide - * @methodOf ngAnimate.$animate - * - * @description - * Sets the element to hidden by adding the `ng-hide` class it. However, before the class is applied - * the following CSS classes will be added temporarily to trigger any animation code: - * - *
- * .ng-hide-add - * .ng-hide-add-active - *- * - * Once the animation is complete then both CSS classes will be removed and `ng-hide` will be added to the element. - * The done callback, if provided, will be also fired once the animation is complete. - * - * @param {jQuery/jqLite element} element the element that will be rendered visible or hidden - * @param {function()=} done callback function that will be called once the animation is complete - */ - hide : function(element, done) { - performAnimation('hide', 'ng-hide-add', element, null, null, function() { - $delegate.hide(element, done); - }); - }, - /** * @ngdoc function * @name ngAnimate.$animate#addClass @@ -617,12 +563,6 @@ angular.module('ngAnimate', ['ng']) move : function(element, done) { return animate(element, 'ng-move', done); }, - show : function(element, done) { - return animate(element, 'ng-hide-remove', done); - }, - hide : function(element, done) { - return animate(element, 'ng-hide-add', done); - }, addClass : function(element, className, done) { return animate(element, className, done); }, -- cgit v1.2.3