Skip to content

Instantly share code, notes, and snippets.

@sdgluck
Last active June 3, 2017 09:30
Show Gist options
  • Save sdgluck/465cfbde9aa1c2cef53b to your computer and use it in GitHub Desktop.
Save sdgluck/465cfbde9aa1c2cef53b to your computer and use it in GitHub Desktop.
An extension of Angular's angular.element prototype with method doAnim; a function to invoke CSS animations.
/**
* Invoke a CSS animation on `this` angular.element instance.
* @param className classname of animation to invoke on `this` element
* @param delay delay before animation is invoked
* @param done callback
*/
angular.element.prototype.doAnim = function(className, delay, done, doneDelay) {
done = (typeof delay === 'function') ? delay : done;
$timeout(function() {
this.removeClass(className);
$timeout(function() {
this.addClass(className);
$timeout(done, doneDelay || 0);
}.bind(this), 100);
}.bind(this), delay || 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment