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

Function animateRun

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

Source from the content-addressed store, hash-verified

1405 }
1406
1407 function animateRun(animationEvent, element, className, activeAnimationComplete) {
1408 var node = extractElementNode(element);
1409 var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1410 if(node.getAttribute('class').indexOf(className) == -1 || !elementData) {
1411 activeAnimationComplete();
1412 return;
1413 }
1414
1415 var activeClassName = '';
1416 forEach(className.split(' '), function(klass, i) {
1417 activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
1418 });
1419
1420 var stagger = elementData.stagger;
1421 var timings = elementData.timings;
1422 var itemIndex = elementData.itemIndex;
1423 var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
1424 var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
1425 var maxDelayTime = maxDelay * ONE_SECOND;
1426
1427 var startTime = Date.now();
1428 var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1429
1430 var style = '', appliedStyles = [];
1431 if(timings.transitionDuration > 0) {
1432 var propertyStyle = timings.transitionPropertyStyle;
1433 if(propertyStyle.indexOf('all') == -1) {
1434 style += CSS_PREFIX + 'transition-property: ' + propertyStyle + ';';
1435 style += CSS_PREFIX + 'transition-duration: ' + timings.transitionDurationStyle + ';';
1436 appliedStyles.push(CSS_PREFIX + 'transition-property');
1437 appliedStyles.push(CSS_PREFIX + 'transition-duration');
1438 }
1439 }
1440
1441 if(itemIndex > 0) {
1442 if(stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
1443 var delayStyle = timings.transitionDelayStyle;
1444 style += CSS_PREFIX + 'transition-delay: ' +
1445 prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + '; ';
1446 appliedStyles.push(CSS_PREFIX + 'transition-delay');
1447 }
1448
1449 if(stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1450 style += CSS_PREFIX + 'animation-delay: ' +
1451 prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + '; ';
1452 appliedStyles.push(CSS_PREFIX + 'animation-delay');
1453 }
1454 }
1455
1456 if(appliedStyles.length > 0) {
1457 //the element being animated may sometimes contain comment nodes in
1458 //the jqLite object, so we're safe to use a single variable to house
1459 //the styles since there is always only one element being animated
1460 var oldStyle = node.getAttribute('style') || '';
1461 node.setAttribute('style', oldStyle + '; ' + style);
1462 }
1463
1464 element.on(css3AnimationEvents, onAnimationProgress);

Callers 1

animateAfterFunction · 0.70

Calls 5

prepareStaggerDelayFunction · 0.85
extractElementNodeFunction · 0.70
forEachFunction · 0.70
onEndFunction · 0.70
animationCloseHandlerFunction · 0.70

Tested by

no test coverage detected