mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-29 13:25:40 +08:00
fix($animate): ensure that animateable directives cancel expired leave animations
If enter -> leave -> enter -> leave occurs then the first leave animation will animate alongside the second. This causes the very first DOM node (the view in ngView for example) to animate at the same time as the most recent DOM node which ends up being an undesired effect. This fix takes care of this issue. Closes #5886
This commit is contained in:
@@ -833,6 +833,50 @@ describe('ngView animations', function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should destroy the previous leave animation if a new one takes place', function() {
|
||||
module(function($provide) {
|
||||
$provide.value('$animate', {
|
||||
enabled : function() { return true; },
|
||||
leave : function() {
|
||||
//DOM operation left blank
|
||||
},
|
||||
enter : function(element, parent, after) {
|
||||
angular.element(after).after(element);
|
||||
}
|
||||
});
|
||||
});
|
||||
inject(function ($compile, $rootScope, $animate, $location) {
|
||||
var item;
|
||||
var $scope = $rootScope.$new();
|
||||
element = $compile(html(
|
||||
'<div>' +
|
||||
'<div ng-view></div>' +
|
||||
'</div>'
|
||||
))($scope);
|
||||
|
||||
$scope.$apply('value = true');
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
var destroyed, inner = element.children(0);
|
||||
inner.on('$destroy', function() {
|
||||
destroyed = true;
|
||||
});
|
||||
|
||||
$location.path('/foo');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
$location.path('/bar');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(destroyed).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user