From da344daa4023556f8abbef6d8ad87a16362b5861 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Tue, 5 Nov 2013 23:53:00 -0800 Subject: fix(ngView): only run anchorScroll after animation is done --- src/ngRoute/directive/ngView.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/ngRoute/directive/ngView.js') diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js index 00e047ca..a8a136df 100644 --- a/src/ngRoute/directive/ngView.js +++ b/src/ngRoute/directive/ngView.js @@ -177,6 +177,7 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, return function(scope, $element, attr) { var currentScope, currentElement, + autoScrollExp = attr.autoscroll, onloadExp = attr.onload || ''; scope.$on('$routeChangeSuccess', update); @@ -201,7 +202,12 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, var newScope = scope.$new(); linker(newScope, function(clone) { clone.html(template); - $animate.enter(clone, null, currentElement || $element); + $animate.enter(clone, null, currentElement || $element, function onNgViewEnter () { + if (angular.isDefined(autoScrollExp) + && (!autoScrollExp || scope.$eval(autoScrollExp))) { + $anchorScroll(); + } + }); cleanupLastView(); @@ -224,9 +230,6 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, link(currentScope); currentScope.$emit('$viewContentLoaded'); currentScope.$eval(onloadExp); - - // $anchorScroll might listen on event... - $anchorScroll(); }); } else { cleanupLastView(); -- cgit v1.2.3