diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 0466cecb1715..269db9227a3b 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -332,9 +332,12 @@ angular.module('ngAnimate', ['ng']) //operation which performs CSS transition and keyframe //animations sniffing. This is always included for each //element animation procedure if the browser supports - //transitions and/or keyframe animations + //transitions and/or keyframe animations. The default + //animation is added to the top of the list to prevent + //any previous animations from affecting the element styling + //prior to the element being animated. if ($sniffer.transitions || $sniffer.animations) { - classes.push(''); + matches.push($injector.get(selectors[''])); } for(var i=0; i < classes.length; i++) { diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index 204ca9c32114..69cb657336fb 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -721,6 +721,37 @@ describe("ngAnimate", function() { }) }); + /* The CSS animation handler must always be rendered before the other JS animation + handlers. This is important since the CSS animation handler may place temporary + styling on the HTML element before the reflow commences which in turn may override + other transition or keyframe styles that any former JS animations may have placed + on the element: https://github.com/angular/angular.js/issues/6675 */ + it("should always perform the CSS animation before the JS animation", function() { + var log = []; + module(function($animateProvider) { + //CSS animation handler + $animateProvider.register('', function() { + return { + leave : function() { log.push('css'); } + } + }); + //custom JS animation handler + $animateProvider.register('.js-animation', function() { + return { + leave : function() { log.push('js'); } + } + }); + }); + inject(function($animate, $rootScope, $compile, $sniffer) { + if(!$sniffer.transitions) return; + + element = $compile(html('
'))($rootScope); + $animate.leave(element); + $rootScope.$digest(); + expect(log).toEqual(['css','js']); + }); + }); + describe("Animations", function() {