(animationEvent, element, className, calculationDecorator)
| 1306 | } |
| 1307 | |
| 1308 | function animateSetup(animationEvent, element, className, calculationDecorator) { |
| 1309 | var cacheKey = getCacheKey(element); |
| 1310 | var eventCacheKey = cacheKey + ' ' + className; |
| 1311 | var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0; |
| 1312 | |
| 1313 | var stagger = {}; |
| 1314 | if(itemIndex > 0) { |
| 1315 | var staggerClassName = className + '-stagger'; |
| 1316 | var staggerCacheKey = cacheKey + ' ' + staggerClassName; |
| 1317 | var applyClasses = !lookupCache[staggerCacheKey]; |
| 1318 | |
| 1319 | applyClasses && element.addClass(staggerClassName); |
| 1320 | |
| 1321 | stagger = getElementAnimationDetails(element, staggerCacheKey); |
| 1322 | |
| 1323 | applyClasses && element.removeClass(staggerClassName); |
| 1324 | } |
| 1325 | |
| 1326 | /* the animation itself may need to add/remove special CSS classes |
| 1327 | * before calculating the anmation styles */ |
| 1328 | calculationDecorator = calculationDecorator || |
| 1329 | function(fn) { return fn(); }; |
| 1330 | |
| 1331 | element.addClass(className); |
| 1332 | |
| 1333 | var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {}; |
| 1334 | |
| 1335 | var timings = calculationDecorator(function() { |
| 1336 | return getElementAnimationDetails(element, eventCacheKey); |
| 1337 | }); |
| 1338 | |
| 1339 | var transitionDuration = timings.transitionDuration; |
| 1340 | var animationDuration = timings.animationDuration; |
| 1341 | if(transitionDuration === 0 && animationDuration === 0) { |
| 1342 | element.removeClass(className); |
| 1343 | return false; |
| 1344 | } |
| 1345 | |
| 1346 | element.data(NG_ANIMATE_CSS_DATA_KEY, { |
| 1347 | running : formerData.running || 0, |
| 1348 | itemIndex : itemIndex, |
| 1349 | stagger : stagger, |
| 1350 | timings : timings, |
| 1351 | closeAnimationFn : noop |
| 1352 | }); |
| 1353 | |
| 1354 | //temporarily disable the transition so that the enter styles |
| 1355 | //don't animate twice (this is here to avoid a bug in Chrome/FF). |
| 1356 | var isCurrentlyAnimating = formerData.running > 0 || animationEvent == 'setClass'; |
| 1357 | if(transitionDuration > 0) { |
| 1358 | blockTransitions(element, className, isCurrentlyAnimating); |
| 1359 | } |
| 1360 | |
| 1361 | //staggering keyframe animations work by adjusting the `animation-delay` CSS property |
| 1362 | //on the given element, however, the delay value can only calculated after the reflow |
| 1363 | //since by that time $animate knows how many elements are being animated. Therefore, |
| 1364 | //until the reflow occurs the element needs to be blocked (where the keyframe animation |
| 1365 | //is set to `none 0s`). This blocking mechanism should only be set for when a stagger |
no test coverage detected