aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ngAnimate/animate.js34
-rw-r--r--test/ngAnimate/animateSpec.js15
2 files changed, 35 insertions, 14 deletions
diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js
index 99b42f38..dba8d3fa 100644
--- a/src/ngAnimate/animate.js
+++ b/src/ngAnimate/animate.js
@@ -627,6 +627,9 @@ angular.module('ngAnimate', ['ng'])
return;
}
+ var elementEvents = angular.element._data(node);
+ elementEvents = elementEvents && elementEvents.events;
+
var animationLookup = (' ' + classes).replace(/\s+/g,'.');
if (!parentElement) {
parentElement = afterElement ? afterElement.parent() : element.parent();
@@ -822,29 +825,32 @@ angular.module('ngAnimate', ['ng'])
}
function fireDOMCallback(animationPhase) {
- element.triggerHandler('$animate:' + animationPhase, {
- event : animationEvent,
- className : className
- });
+ var eventName = '$animate:' + animationPhase;
+ if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
+ $$asyncQueueBuffer(function() {
+ element.triggerHandler(eventName, {
+ event : animationEvent,
+ className : className
+ });
+ });
+ }
}
function fireBeforeCallbackAsync() {
- $$asyncQueueBuffer(function() {
- fireDOMCallback('before');
- });
+ fireDOMCallback('before');
}
function fireAfterCallbackAsync() {
- $$asyncQueueBuffer(function() {
- fireDOMCallback('after');
- });
+ fireDOMCallback('after');
}
function fireDoneCallbackAsync() {
- $$asyncQueueBuffer(function() {
- fireDOMCallback('close');
- doneCallback && doneCallback();
- });
+ fireDOMCallback('close');
+ if(doneCallback) {
+ $$asyncQueueBuffer(function() {
+ doneCallback();
+ });
+ }
}
//it is less complicated to use a flag than managing and cancelling
diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js
index 41115e42..8da3d1cb 100644
--- a/test/ngAnimate/animateSpec.js
+++ b/test/ngAnimate/animateSpec.js
@@ -1573,6 +1573,21 @@ describe("ngAnimate", function() {
expect(steps.shift()).toEqual(['after', 'ng-enter', 'enter']);
}));
+ it('should not fire DOM callbacks on the element being animated unless registered',
+ inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {
+
+ $animate.enabled(true);
+
+ var element = jqLite('<div></div>');
+ $rootElement.append(element);
+ body.append($rootElement);
+
+ $animate.addClass(element, 'class');
+ $rootScope.$digest();
+
+ $timeout.verifyNoPendingTasks();
+ }));
+
it("should fire a done callback when provided with no animation",
inject(function($animate, $rootScope, $compile, $sniffer, $rootElement, $timeout) {