| 5937 | * Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}. |
| 5938 | */ |
| 5939 | var $CoreAnimateCssProvider = function() { |
| 5940 | this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) { |
| 5941 | |
| 5942 | return function(element, initialOptions) { |
| 5943 | // all of the animation functions should create |
| 5944 | // a copy of the options data, however, if a |
| 5945 | // parent service has already created a copy then |
| 5946 | // we should stick to using that |
| 5947 | var options = initialOptions || {}; |
| 5948 | if (!options.$$prepared) { |
| 5949 | options = copy(options); |
| 5950 | } |
| 5951 | |
| 5952 | // there is no point in applying the styles since |
| 5953 | // there is no animation that goes on at all in |
| 5954 | // this version of $animateCss. |
| 5955 | if (options.cleanupStyles) { |
| 5956 | options.from = options.to = null; |
| 5957 | } |
| 5958 | |
| 5959 | if (options.from) { |
| 5960 | element.css(options.from); |
| 5961 | options.from = null; |
| 5962 | } |
| 5963 | |
| 5964 | var closed, runner = new $$AnimateRunner(); |
| 5965 | return { |
| 5966 | start: run, |
| 5967 | end: run |
| 5968 | }; |
| 5969 | |
| 5970 | function run() { |
| 5971 | $$rAF(function() { |
| 5972 | applyAnimationContents(); |
| 5973 | if (!closed) { |
| 5974 | runner.complete(); |
| 5975 | } |
| 5976 | closed = true; |
| 5977 | }); |
| 5978 | return runner; |
| 5979 | } |
| 5980 | |
| 5981 | function applyAnimationContents() { |
| 5982 | if (options.addClass) { |
| 5983 | element.addClass(options.addClass); |
| 5984 | options.addClass = null; |
| 5985 | } |
| 5986 | if (options.removeClass) { |
| 5987 | element.removeClass(options.removeClass); |
| 5988 | options.removeClass = null; |
| 5989 | } |
| 5990 | if (options.to) { |
| 5991 | element.css(options.to); |
| 5992 | options.to = null; |
| 5993 | } |
| 5994 | } |
| 5995 | }; |
| 5996 | }]; |