diff options
Diffstat (limited to 'src/ng/directive/ngShowHide.js')
| -rw-r--r-- | src/ng/directive/ngShowHide.js | 64 | 
1 files changed, 28 insertions, 36 deletions
| diff --git a/src/ng/directive/ngShowHide.js b/src/ng/directive/ngShowHide.js index 7ef7008c..bdbcf463 100644 --- a/src/ng/directive/ngShowHide.js +++ b/src/ng/directive/ngShowHide.js @@ -12,8 +12,6 @@   * With ngHide this is the reverse whereas true values cause the element itself to become   * hidden.   * - * Additionally, you can also provide animations via the ngAnimate attribute to animate the **show** - * and **hide** effects.   *   * @animations   * show - happens after the ngShow expression evaluates to a truthy value and the contents are set to visible @@ -29,36 +27,37 @@        Click me: <input type="checkbox" ng-model="checked"><br/>        <div>          Show: -        <span class="check-element" -              ng-show="checked" -              ng-animate="{show: 'example-show', hide: 'example-hide'}"> +        <span class="check-element example-show-hide" ng-show="checked">            <span class="icon-thumbs-up"></span> I show up when your checkbox is checked.          </span>        </div>        <div>          Hide: -        <span class="check-element" -              ng-hide="checked" -              ng-animate="{show: 'example-show', hide: 'example-hide'}"> +        <span class="check-element example-show-hide" ng-hide="checked">            <span class="icon-thumbs-down"></span> I hide when your checkbox is checked.          </span>        </div>      </file>      <file name="animations.css"> -      .example-show, .example-hide { +      .example-show-hide {          -webkit-transition:all linear 0.5s;          -moz-transition:all linear 0.5s;          -ms-transition:all linear 0.5s;          -o-transition:all linear 0.5s;          transition:all linear 0.5s; +        display:block; +      } +      .example-show-hide.ng-hide { +        display:none;        } -      .example-show { +      .example-show-hide.ng-hide-remove { +        display:block;          line-height:0;          opacity:0;          padding:0 10px;        } -      .example-show-active.example-show-active { +      .example-show-hide.ng-hide-remove.ng-hide-remove-active {          line-height:20px;          opacity:1;          padding:10px; @@ -66,14 +65,14 @@          background:white;        } -      .example-hide { +      .example-show-hide.ng-hide-add {          line-height:20px;          opacity:1;          padding:10px;          border:1px solid black;          background:white;        } -      .example-hide-active.example-hide-active { +      .example-show-hide.ng-hide-add.ng-hide-add-active {          line-height:0;          opacity:0;          padding:0 10px; @@ -98,12 +97,10 @@      </file>    </example>   */ -//TODO(misko): refactor to remove element from the DOM -var ngShowDirective = ['$animator', function($animator) { +var ngShowDirective = ['$animate', function($animate) {    return function(scope, element, attr) { -    var animate = $animator(scope, attr);      scope.$watch(attr.ngShow, function ngShowWatchAction(value){ -      animate[toBoolean(value) ? 'show' : 'hide'](element); +      $animate[toBoolean(value) ? 'show' : 'hide'](element);      });    };  }]; @@ -121,9 +118,6 @@ var ngShowDirective = ['$animator', function($animator) {   * With ngHide this is the reverse whereas true values cause the element itself to become   * hidden.   * - * Additionally, you can also provide animations via the ngAnimate attribute to animate the **show** - * and **hide** effects. - *   * @animations   * show - happens after the ngHide expression evaluates to a non truthy value and the contents are set to visible   * hide - happens after the ngHide expression evaluates to a truthy value and just before the contents are set to hidden @@ -138,36 +132,36 @@ var ngShowDirective = ['$animator', function($animator) {        Click me: <input type="checkbox" ng-model="checked"><br/>        <div>          Show: -        <span class="check-element" -              ng-show="checked" -              ng-animate="{show: 'example-show', hide: 'example-hide'}"> +        <span class="check-element example-show-hide" ng-show="checked">            <span class="icon-thumbs-up"></span> I show up when your checkbox is checked.          </span>        </div>        <div>          Hide: -        <span class="check-element" -              ng-hide="checked" -              ng-animate="{show: 'example-show', hide: 'example-hide'}"> +        <span class="check-element example-show-hide" ng-hide="checked">            <span class="icon-thumbs-down"></span> I hide when your checkbox is checked.          </span>        </div>      </file>      <file name="animations.css"> -      .example-show, .example-hide { +      .example-show-hide {          -webkit-transition:all linear 0.5s;          -moz-transition:all linear 0.5s; -        -ms-transition:all linear 0.5s;          -o-transition:all linear 0.5s;          transition:all linear 0.5s; +        display:block; +      } +      .example-show-hide.ng-hide { +        display:none;        } -      .example-show { +      .example-show-hide.ng-hide-remove { +        display:block;          line-height:0;          opacity:0;          padding:0 10px;        } -      .example-show.example-show-active { +      .example-show-hide.ng-hide-remove.ng-hide-remove-active {          line-height:20px;          opacity:1;          padding:10px; @@ -175,14 +169,14 @@ var ngShowDirective = ['$animator', function($animator) {          background:white;        } -      .example-hide { +      .example-show-hide.ng-hide-add {          line-height:20px;          opacity:1;          padding:10px;          border:1px solid black;          background:white;        } -      .example-hide.example-hide-active { +      .example-show-hide.ng-hide-add.ng-hide-add-active {          line-height:0;          opacity:0;          padding:0 10px; @@ -207,12 +201,10 @@ var ngShowDirective = ['$animator', function($animator) {      </file>    </example>   */ -//TODO(misko): refactor to remove element from the DOM -var ngHideDirective = ['$animator', function($animator) { +var ngHideDirective = ['$animate', function($animate) {    return function(scope, element, attr) { -    var animate = $animator(scope, attr);      scope.$watch(attr.ngHide, function ngHideWatchAction(value){ -      animate[toBoolean(value) ? 'hide' : 'show'](element); +      $animate[toBoolean(value) ? 'hide' : 'show'](element);      });    };  }]; | 
