Skip to content

Instantly share code, notes, and snippets.

@boneskull
Created August 2, 2012 18:32
Show Gist options
  • Save boneskull/3239476 to your computer and use it in GitHub Desktop.
Save boneskull/3239476 to your computer and use it in GitHub Desktop.
directive to fade in a node
// <div fade-in="some_boolean">BOOM</div>
myApp.directive('fadeIn', function() {
return {
restrict: 'A',
link: function(scope, element, attribs) {
scope.$watch(attribs.fadeIn, 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