-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
We need to wait until animations have added the content to the document before trying to `autoscroll` to anchors that may have been inserted. Fixes angular#4723
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,6 +178,13 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile' | |
}; | ||
|
||
scope.$watch($sce.parseAsResourceUrl(srcExp), function ngIncludeWatchAction(src) { | ||
var afterAnimation = function() { | ||
|
||
if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { | ||
$anchorScroll(); | ||
} | ||
|
||
}; | ||
var thisChangeId = ++changeCounter; | ||
|
||
if (src) { | ||
|
@@ -192,13 +199,8 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile' | |
currentElement = clone; | ||
|
||
currentElement.html(response); | ||
$animate.enter(currentElement, null, $element); | ||
$animate.enter(currentElement, null, $element, afterAnimation); | ||
$compile(currentElement.contents())(currentScope); | ||
|
||
if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { | ||
$anchorScroll(); | ||
} | ||
|
||
currentScope.$emit('$includeContentLoaded'); | ||
scope.$eval(onloadExp); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
petebacondarwin
Author
Owner
|
||
}); | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -322,22 +322,36 @@ describe('ngInclude', function() { | |||
}; | ||||
} | ||||
|
||||
function spyOnAnimateEnter() { | ||||
return function($animate) { | ||||
spyOn($animate, 'enter').andCallThrough(); | ||||
}; | ||||
} | ||||
|
||||
function runEnterAnimation($animate) { | ||||
if ($animate.enter.mostRecentCall) { | ||||
$animate.enter.mostRecentCall.args[3](); | ||||
This comment has been minimized.
Sorry, something went wrong.
IgorMinar
|
beforeEach(module('mock.animate')); |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
petebacondarwin
Nov 5, 2013
Author
Owner
mock.animate brings a whole new set of issue. Naive use causes LEAK errors. We have to then make sure that the elements are attached and dealoc'ed correctly. Plus you still need to call $animate.flush() all over the place.
2 comments
on commit 732ca80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need a similar fix for ngView?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with igor. Neen same for ngView
I think that this $emit and $eval should stay here at least until we have a usecase where it needs to execute after the animation is done.
I can be convinced otherwise if you have some real world scenarios where this would not work.