| 6311 | * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}. |
| 6312 | */ |
| 6313 | var $CoreAnimateCssProvider = function() { |
| 6314 | this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) { |
| 6315 | |
| 6316 | return function(element, initialOptions) { |
| 6317 | // all of the animation functions should create |
| 6318 | // a copy of the options data, however, if a |
| 6319 | // parent service has already created a copy then |
| 6320 | // we should stick to using that |
| 6321 | var options = initialOptions || {}; |
| 6322 | if (!options.$$prepared) { |
| 6323 | options = copy(options); |
| 6324 | } |
| 6325 | |
| 6326 | // there is no point in applying the styles since |
| 6327 | // there is no animation that goes on at all in |
| 6328 | // this version of $animateCss. |
| 6329 | if (options.cleanupStyles) { |
| 6330 | options.from = options.to = null; |
| 6331 | } |
| 6332 | |
| 6333 | if (options.from) { |
| 6334 | element.css(options.from); |
| 6335 | options.from = null; |
| 6336 | } |
| 6337 | |
| 6338 | var closed, runner = new $$AnimateRunner(); |
| 6339 | return { |
| 6340 | start: run, |
| 6341 | end: run |
| 6342 | }; |
| 6343 | |
| 6344 | function run() { |
| 6345 | $$rAF(function() { |
| 6346 | applyAnimationContents(); |
| 6347 | if (!closed) { |
| 6348 | runner.complete(); |
| 6349 | } |
| 6350 | closed = true; |
| 6351 | }); |
| 6352 | return runner; |
| 6353 | } |
| 6354 | |
| 6355 | function applyAnimationContents() { |
| 6356 | if (options.addClass) { |
| 6357 | element.addClass(options.addClass); |
| 6358 | options.addClass = null; |
| 6359 | } |
| 6360 | if (options.removeClass) { |
| 6361 | element.removeClass(options.removeClass); |
| 6362 | options.removeClass = null; |
| 6363 | } |
| 6364 | if (options.to) { |
| 6365 | element.css(options.to); |
| 6366 | options.to = null; |
| 6367 | } |
| 6368 | } |
| 6369 | }; |
| 6370 | }]; |