Skip to content

Commit 3485089

Browse files
committed
Some ng-animate tweaks (see #85)
Still need to guard against $animator not being defined. Also avoid having two variables 'doAnimate' in scope to make the code clearer.
1 parent 35b83e0 commit 3485089

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/viewDirective.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
1111
var viewScope, viewLocals,
1212
name = attr[directive.name] || attr.name || '',
1313
onloadExp = attr.onload || '',
14-
doAnimate = isDefined($animator),
15-
animate = $animator(scope, attr);
14+
animate = isDefined($animator) && $animator(scope, attr);
1615

1716
// Find the details of the parent view directive (if any) and use it
1817
// to derive our own qualified view name, then hang our own details
@@ -22,7 +21,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
2221
var view = { name: name, state: null };
2322
element.data('$uiView', view);
2423

25-
scope.$on('$stateChangeSuccess', function() { updateView(doAnimate); });
24+
scope.$on('$stateChangeSuccess', function() { updateView(true); });
2625
updateView(false);
2726

2827
function updateView(doAnimate) {
@@ -31,7 +30,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
3130

3231
// Destroy previous view scope and remove content (if any)
3332
if (viewScope) {
34-
if (doAnimate) animate.leave(element.contents(), element);
33+
if (animate && doAnimate) animate.leave(element.contents(), element);
3534
else element.html('');
3635

3736
viewScope.$destroy();
@@ -43,7 +42,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an
4342
view.state = locals.$$state;
4443

4544
var contents;
46-
if (doAnimate) {
45+
if (animate && doAnimate) {
4746
contents = angular.element('<div></div>').html(locals.$template).contents();
4847
animate.enter(contents, element);
4948
} else {

0 commit comments

Comments
 (0)