Created
July 18, 2012 18:56
-
-
Save boneskull/3138069 to your computer and use it in GitHub Desktop.
angular directive to fadeIn/hide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fades an element in when the model changes. Restricted to attributes. | |
* | |
* Usage: | |
* | |
* <div di-fade-in="foo"/> | |
*/ | |
di.directive('diFadeIn', function () { | |
return { | |
restrict: 'A', | |
link: function (scope, element, attribs) { | |
scope.$watch(attribs.diFadeIn, function (value) { | |
if (value) { | |
element.fadeIn(); | |
} else { | |
element.hide(); // hide immediately; don't fade out | |
} | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment