From bc8c5257e80d27f2d9a545c34d6776e4e63589cc Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Sat, 27 Jul 2013 16:53:11 +0100 Subject: fix(animate): move forEach so it can be accessed as needed --- src/ngAnimate/animate.js | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 7eef1c34..e7c6d5a1 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -183,6 +183,9 @@ * */ +var noop = angular.noop; +var forEach = angular.forEach; + angular.module('ngAnimate', ['ng']) /** @@ -202,26 +205,23 @@ angular.module('ngAnimate', ['ng']) var NG_ANIMATE_STATE = '$$ngAnimateState'; var rootAnimateState = {running:true}; - $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$timeout', function($delegate, $injector, $sniffer, $rootElement, $timeout) { - var noop = angular.noop; - var forEach = angular.forEach; - $rootElement.data(NG_ANIMATE_STATE, rootAnimateState); function lookup(name) { + var i, ii; if (name) { var classes = name.substr(1).split('.'), classMap = {}; - for (var i = 0, ii = classes.length; i < ii; i++) { + for (i = 0, ii = classes.length; i < ii; i++) { classMap[classes[i]] = true; } var matches = []; - for (var i = 0, ii = selectors.length; i < ii; i++) { + for (i = 0, ii = selectors.length; i < ii; i++) { var selectorFactory = selectors[i]; var found = true; for(var j = 0, jj = selectorFactory.selectors.length; j < jj; j++) { @@ -236,7 +236,7 @@ angular.module('ngAnimate', ['ng']) } return matches; } - }; + } /** * @ngdoc object @@ -532,7 +532,7 @@ angular.module('ngAnimate', ['ng']) if(!animations[i].done) return; } done(); - }; + } function done() { if(!done.hasBeenRun) { @@ -547,24 +547,6 @@ angular.module('ngAnimate', ['ng']) }]) .animation('', ['$window','$sniffer', '$timeout', function($window, $sniffer, $timeout) { - return { - enter : function(element, done) { - return animate(element, 'ng-enter', done); - }, - leave : function(element, done) { - return animate(element, 'ng-leave', done); - }, - move : function(element, done) { - return animate(element, 'ng-move', done); - }, - addClass : function(element, className, done) { - return animate(element, className, done); - }, - removeClass : function(element, className, done) { - return animate(element, className, done); - } - }; - function animate(element, className, done) { if (!($sniffer.transitions || $sniffer.animations)) { done(); @@ -652,6 +634,25 @@ angular.module('ngAnimate', ['ng']) if(cancelled) { done(); } - }; + } + } + + return { + enter : function(element, done) { + return animate(element, 'ng-enter', done); + }, + leave : function(element, done) { + return animate(element, 'ng-leave', done); + }, + move : function(element, done) { + return animate(element, 'ng-move', done); + }, + addClass : function(element, className, done) { + return animate(element, className, done); + }, + removeClass : function(element, className, done) { + return animate(element, className, done); + } }; + }]); -- cgit v1.2.3