MCPcopy
hub / github.com/angular-ui/ui-router / animationRunner

Function animationRunner

test/angular/1.3/angular-animate.js:634–797  ·  view source on GitHub ↗
(element, animationEvent, className, options)

Source from the content-addressed store, hash-verified

632 }
633
634 function animationRunner(element, animationEvent, className, options) {
635 //transcluded directives may sometimes fire an animation using only comment nodes
636 //best to catch this early on to prevent any animation operations from occurring
637 var node = element[0];
638 if (!node) {
639 return;
640 }
641
642 if (options) {
643 options.to = options.to || {};
644 options.from = options.from || {};
645 }
646
647 var classNameAdd;
648 var classNameRemove;
649 if (isArray(className)) {
650 classNameAdd = className[0];
651 classNameRemove = className[1];
652 if (!classNameAdd) {
653 className = classNameRemove;
654 animationEvent = 'removeClass';
655 } else if (!classNameRemove) {
656 className = classNameAdd;
657 animationEvent = 'addClass';
658 } else {
659 className = classNameAdd + ' ' + classNameRemove;
660 }
661 }
662
663 var isSetClassOperation = animationEvent == 'setClass';
664 var isClassBased = isSetClassOperation
665 || animationEvent == 'addClass'
666 || animationEvent == 'removeClass'
667 || animationEvent == 'animate';
668
669 var currentClassName = element.attr('class');
670 var classes = currentClassName + ' ' + className;
671 if (!isAnimatableClassName(classes)) {
672 return;
673 }
674
675 var beforeComplete = noop,
676 beforeCancel = [],
677 before = [],
678 afterComplete = noop,
679 afterCancel = [],
680 after = [];
681
682 var animationLookup = (' ' + classes).replace(/\s+/g,'.');
683 forEach(lookup(animationLookup), function(animationFactory) {
684 var created = registerAnimation(animationFactory, animationEvent);
685 if (!created && isSetClassOperation) {
686 registerAnimation(animationFactory, 'addClass');
687 registerAnimation(animationFactory, 'removeClass');
688 }
689 });
690
691 function registerAnimation(animationFactory, event) {

Callers 1

performAnimationFunction · 0.70

Calls 5

isArrayFunction · 0.85
forEachFunction · 0.70
lookupFunction · 0.70
registerAnimationFunction · 0.70
runFunction · 0.70

Tested by

no test coverage detected