| 6331 | * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}. |
| 6332 | */ |
| 6333 | var $CoreAnimateCssProvider = function() { |
| 6334 | this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) { |
| 6335 | |
| 6336 | return function(element, initialOptions) { |
| 6337 | // all of the animation functions should create |
| 6338 | // a copy of the options data, however, if a |
| 6339 | // parent service has already created a copy then |
| 6340 | // we should stick to using that |
| 6341 | var options = initialOptions || {}; |
| 6342 | if (!options.$$prepared) { |
| 6343 | options = copy(options); |
| 6344 | } |
| 6345 | |
| 6346 | // there is no point in applying the styles since |
| 6347 | // there is no animation that goes on at all in |
| 6348 | // this version of $animateCss. |
| 6349 | if (options.cleanupStyles) { |
| 6350 | options.from = options.to = null; |
| 6351 | } |
| 6352 | |
| 6353 | if (options.from) { |
| 6354 | element.css(options.from); |
| 6355 | options.from = null; |
| 6356 | } |
| 6357 | |
| 6358 | var closed, runner = new $$AnimateRunner(); |
| 6359 | return { |
| 6360 | start: run, |
| 6361 | end: run |
| 6362 | }; |
| 6363 | |
| 6364 | function run() { |
| 6365 | $$rAF(function() { |
| 6366 | applyAnimationContents(); |
| 6367 | if (!closed) { |
| 6368 | runner.complete(); |
| 6369 | } |
| 6370 | closed = true; |
| 6371 | }); |
| 6372 | return runner; |
| 6373 | } |
| 6374 | |
| 6375 | function applyAnimationContents() { |
| 6376 | if (options.addClass) { |
| 6377 | element.addClass(options.addClass); |
| 6378 | options.addClass = null; |
| 6379 | } |
| 6380 | if (options.removeClass) { |
| 6381 | element.removeClass(options.removeClass); |
| 6382 | options.removeClass = null; |
| 6383 | } |
| 6384 | if (options.to) { |
| 6385 | element.css(options.to); |
| 6386 | options.to = null; |
| 6387 | } |
| 6388 | } |
| 6389 | }; |
| 6390 | }]; |