MCPcopy Index your code
hub / github.com/angular-ui/ui-router / animationRunner

Function animationRunner

test/angular/1.2/angular-animate.js:401–541  ·  view source on GitHub ↗
(element, animationEvent, className)

Source from the content-addressed store, hash-verified

399 }
400
401 function animationRunner(element, animationEvent, className) {
402 //transcluded directives may sometimes fire an animation using only comment nodes
403 //best to catch this early on to prevent any animation operations from occurring
404 var node = element[0];
405 if(!node) {
406 return;
407 }
408
409 var isSetClassOperation = animationEvent == 'setClass';
410 var isClassBased = isSetClassOperation ||
411 animationEvent == 'addClass' ||
412 animationEvent == 'removeClass';
413
414 var classNameAdd, classNameRemove;
415 if(angular.isArray(className)) {
416 classNameAdd = className[0];
417 classNameRemove = className[1];
418 className = classNameAdd + ' ' + classNameRemove;
419 }
420
421 var currentClassName = element.attr('class');
422 var classes = currentClassName + ' ' + className;
423 if(!isAnimatableClassName(classes)) {
424 return;
425 }
426
427 var beforeComplete = noop,
428 beforeCancel = [],
429 before = [],
430 afterComplete = noop,
431 afterCancel = [],
432 after = [];
433
434 var animationLookup = (' ' + classes).replace(/\s+/g,'.');
435 forEach(lookup(animationLookup), function(animationFactory) {
436 var created = registerAnimation(animationFactory, animationEvent);
437 if(!created && isSetClassOperation) {
438 registerAnimation(animationFactory, 'addClass');
439 registerAnimation(animationFactory, 'removeClass');
440 }
441 });
442
443 function registerAnimation(animationFactory, event) {
444 var afterFn = animationFactory[event];
445 var beforeFn = animationFactory['before' + event.charAt(0).toUpperCase() + event.substr(1)];
446 if(afterFn || beforeFn) {
447 if(event == 'leave') {
448 beforeFn = afterFn;
449 //when set as null then animation knows to skip this phase
450 afterFn = null;
451 }
452 after.push({
453 event : event, fn : afterFn
454 });
455 before.push({
456 event : event, fn : beforeFn
457 });
458 return true;

Callers 1

performAnimationFunction · 0.70

Calls 4

forEachFunction · 0.70
lookupFunction · 0.70
registerAnimationFunction · 0.70
runFunction · 0.70

Tested by

no test coverage detected