2 * Angular Material Design
3 * https://github.com/angular/material
7 goog.provide('ngmaterial.components.showHide');
8 goog.require('ngmaterial.core');
11 * @name material.components.showHide
14 // Add additional handlers to ng-show and ng-hide that notify directives
15 // contained within that they should recompute their size.
16 // These run in addition to Angular's built-in ng-hide and ng-show directives.
17 angular.module('material.components.showHide', [
20 .directive('ngShow', createDirective('ngShow', true))
21 .directive('ngHide', createDirective('ngHide', false));
24 function createDirective(name, targetValue) {
25 return ['$mdUtil', '$window', function($mdUtil, $window) {
29 link: function($scope, $element, $attr) {
30 var unregister = $scope.$on('$md-resize-enable', function() {
33 var node = $element[0];
34 var cachedTransitionStyles = node.nodeType === $window.Node.ELEMENT_NODE ?
35 $window.getComputedStyle(node) : {};
37 $scope.$watch($attr[name], function(value) {
38 if (!!value === targetValue) {
39 $mdUtil.nextTick(function() {
40 $scope.$broadcast('$md-resize');
44 cachedTransitionStyles: cachedTransitionStyles
47 $mdUtil.dom.animator.waitTransitionEnd($element, opts).then(function() {
48 $scope.$broadcast('$md-resize');
58 ngmaterial.components.showHide = angular.module("material.components.showHide");