aboutsummaryrefslogtreecommitdiffstats
path: root/src/ngRoute/directive/ngView.js
diff options
context:
space:
mode:
authorMatias Niemelä2014-02-21 03:43:50 -0500
committerMatias Niemelä2014-02-26 14:53:57 -0500
commite9881991ca0a5019d3a4215477738ed247898ba0 (patch)
tree5bca5a431522715543288b94772882dcd994bbe2 /src/ngRoute/directive/ngView.js
parentc9245cf759108add2a10ffca4d41b1c68c1e8c76 (diff)
downloadangular.js-e9881991ca0a5019d3a4215477738ed247898ba0.tar.bz2
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
Diffstat (limited to 'src/ngRoute/directive/ngView.js')
-rw-r--r--src/ngRoute/directive/ngView.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js
index 3fa851a7..448e375c 100644
--- a/src/ngRoute/directive/ngView.js
+++ b/src/ngRoute/directive/ngView.js
@@ -189,6 +189,7 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
link: function(scope, $element, attr, ctrl, $transclude) {
var currentScope,
currentElement,
+ previousElement,
autoScrollExp = attr.autoscroll,
onloadExp = attr.onload || '';
@@ -196,12 +197,19 @@ function ngViewFactory( $route, $anchorScroll, $animate) {
update();
function cleanupLastView() {
- if (currentScope) {
+ if(previousElement) {
+ previousElement.remove();
+ previousElement = null;
+ }
+ if(currentScope) {
currentScope.$destroy();
currentScope = null;
}
if(currentElement) {
- $animate.leave(currentElement);
+ $animate.leave(currentElement, function() {
+ previousElement = null;
+ });
+ previousElement = currentElement;
currentElement = null;
}
}