(animationEvent, className, element, parentElement, afterElement, domOperation, options, doneCallback)
| 1285 | and the onComplete callback will be fired once the animation is fully complete. |
| 1286 | */ |
| 1287 | function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, options, doneCallback) { |
| 1288 | var noopCancel = noop; |
| 1289 | var runner = animationRunner(element, animationEvent, className, options); |
| 1290 | if (!runner) { |
| 1291 | fireDOMOperation(); |
| 1292 | fireBeforeCallbackAsync(); |
| 1293 | fireAfterCallbackAsync(); |
| 1294 | closeAnimation(); |
| 1295 | return noopCancel; |
| 1296 | } |
| 1297 | |
| 1298 | animationEvent = runner.event; |
| 1299 | className = runner.className; |
| 1300 | var elementEvents = angular.element._data(runner.node); |
| 1301 | elementEvents = elementEvents && elementEvents.events; |
| 1302 | |
| 1303 | if (!parentElement) { |
| 1304 | parentElement = afterElement ? afterElement.parent() : element.parent(); |
| 1305 | } |
| 1306 | |
| 1307 | //skip the animation if animations are disabled, a parent is already being animated, |
| 1308 | //the element is not currently attached to the document body or then completely close |
| 1309 | //the animation if any matching animations are not found at all. |
| 1310 | //NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found. |
| 1311 | if (animationsDisabled(element, parentElement)) { |
| 1312 | fireDOMOperation(); |
| 1313 | fireBeforeCallbackAsync(); |
| 1314 | fireAfterCallbackAsync(); |
| 1315 | closeAnimation(); |
| 1316 | return noopCancel; |
| 1317 | } |
| 1318 | |
| 1319 | var ngAnimateState = element.data(NG_ANIMATE_STATE) || {}; |
| 1320 | var runningAnimations = ngAnimateState.active || {}; |
| 1321 | var totalActiveAnimations = ngAnimateState.totalActive || 0; |
| 1322 | var lastAnimation = ngAnimateState.last; |
| 1323 | var skipAnimation = false; |
| 1324 | |
| 1325 | if (totalActiveAnimations > 0) { |
| 1326 | var animationsToCancel = []; |
| 1327 | if (!runner.isClassBased) { |
| 1328 | if (animationEvent == 'leave' && runningAnimations['ng-leave']) { |
| 1329 | skipAnimation = true; |
| 1330 | } else { |
| 1331 | //cancel all animations when a structural animation takes place |
| 1332 | for (var klass in runningAnimations) { |
| 1333 | animationsToCancel.push(runningAnimations[klass]); |
| 1334 | } |
| 1335 | ngAnimateState = {}; |
| 1336 | cleanup(element, true); |
| 1337 | } |
| 1338 | } else if (lastAnimation.event == 'setClass') { |
| 1339 | animationsToCancel.push(lastAnimation); |
| 1340 | cleanup(element, className); |
| 1341 | } else if (runningAnimations[className]) { |
| 1342 | var current = runningAnimations[className]; |
| 1343 | if (current.event == animationEvent) { |
| 1344 | skipAnimation = true; |
no test coverage detected