| 6371 | * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}. |
| 6372 | */ |
| 6373 | var $CoreAnimateCssProvider = function() { |
| 6374 | this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) { |
| 6375 | |
| 6376 | return function(element, initialOptions) { |
| 6377 | // all of the animation functions should create |
| 6378 | // a copy of the options data, however, if a |
| 6379 | // parent service has already created a copy then |
| 6380 | // we should stick to using that |
| 6381 | var options = initialOptions || {}; |
| 6382 | if (!options.$$prepared) { |
| 6383 | options = copy(options); |
| 6384 | } |
| 6385 | |
| 6386 | // there is no point in applying the styles since |
| 6387 | // there is no animation that goes on at all in |
| 6388 | // this version of $animateCss. |
| 6389 | if (options.cleanupStyles) { |
| 6390 | options.from = options.to = null; |
| 6391 | } |
| 6392 | |
| 6393 | if (options.from) { |
| 6394 | element.css(options.from); |
| 6395 | options.from = null; |
| 6396 | } |
| 6397 | |
| 6398 | var closed, runner = new $$AnimateRunner(); |
| 6399 | return { |
| 6400 | start: run, |
| 6401 | end: run |
| 6402 | }; |
| 6403 | |
| 6404 | function run() { |
| 6405 | $$rAF(function() { |
| 6406 | applyAnimationContents(); |
| 6407 | if (!closed) { |
| 6408 | runner.complete(); |
| 6409 | } |
| 6410 | closed = true; |
| 6411 | }); |
| 6412 | return runner; |
| 6413 | } |
| 6414 | |
| 6415 | function applyAnimationContents() { |
| 6416 | if (options.addClass) { |
| 6417 | element.addClass(options.addClass); |
| 6418 | options.addClass = null; |
| 6419 | } |
| 6420 | if (options.removeClass) { |
| 6421 | element.removeClass(options.removeClass); |
| 6422 | options.removeClass = null; |
| 6423 | } |
| 6424 | if (options.to) { |
| 6425 | element.css(options.to); |
| 6426 | options.to = null; |
| 6427 | } |
| 6428 | } |
| 6429 | }; |
| 6430 | }]; |