-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(viewDirective): $destroy event is triggered before animation ends
when view is animated using ngAnimate, $destroy event is triggered before animation ends. closes #1643
- Loading branch information
Teemu Kokkonen
committed
Oct 30, 2015
1 parent
d23e9fa
commit 1be1379
Showing
2 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,32 +190,45 @@ function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate) | |
updateView(true); | ||
|
||
function cleanupLastView() { | ||
if (previousEl) { | ||
previousEl.remove(); | ||
previousEl = null; | ||
var _previousEl = previousEl; | ||
var _currentScope = currentScope; | ||
|
||
if (_currentScope) { | ||
_currentScope._willBeDestroyed = true; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nateabele
Contributor
|
||
} | ||
|
||
if (currentScope) { | ||
currentScope.$destroy(); | ||
currentScope = null; | ||
function cleanOld() { | ||
if (_previousEl) { | ||
_previousEl.remove(); | ||
} | ||
|
||
if (_currentScope) { | ||
_currentScope.$destroy(); | ||
} | ||
} | ||
|
||
if (currentEl) { | ||
renderer.leave(currentEl, function() { | ||
cleanOld(); | ||
This comment has been minimized.
Sorry, something went wrong.
christopherthielen
Contributor
|
||
previousEl = null; | ||
}); | ||
|
||
previousEl = currentEl; | ||
currentEl = null; | ||
} else { | ||
cleanOld(); | ||
previousEl = null; | ||
} | ||
|
||
currentEl = null; | ||
currentScope = null; | ||
} | ||
|
||
function updateView(firstTime) { | ||
var newScope, | ||
name = getUiViewName(scope, attrs, $element, $interpolate), | ||
previousLocals = name && $state.$current && $state.$current.locals[name]; | ||
|
||
if (!firstTime && previousLocals === latestLocals) return; // nothing to do | ||
if (!firstTime && previousLocals === latestLocals || scope._willBeDestroyed) return; // nothing to do | ||
newScope = scope.$new(); | ||
latestLocals = $state.$current.locals[name]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is this true resetting? Or should it just be destroy if in the current scope?