Skip to content

Commit

Permalink
fix(uiView): don't animate initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
nateabele committed Dec 28, 2013
1 parent a402415 commit 83b6634
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
if (viewIsUpdating) return;
viewIsUpdating = true;

try { updateView(); } catch (e) {
try { updateView(true); } catch (e) {
viewIsUpdating = false;
throw e;
}
Expand All @@ -104,7 +104,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
$scope.$on('$stateChangeSuccess', eventHook);
$scope.$on('$viewContentLoading', eventHook);

updateView();
updateView(false);

function cleanupLastView() {
if (currentEl) {
Expand All @@ -118,7 +118,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
}
}

function updateView() {
function updateView(shouldAnimate) {
var locals = $state.$current && $state.$current.locals[name];

if (isDefault) {
Expand All @@ -130,7 +130,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
cleanupLastView();
currentEl = element.clone();
currentEl.html(initial);
anchor.after(currentEl);
renderer(shouldAnimate).enter(currentEl, parentEl, anchor);

currentScope = $scope.$new();
$compile(currentEl.contents())(currentScope);
Expand Down
2 changes: 2 additions & 0 deletions test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe('uiView', function () {

$animate.flushNext('enter');
$animate.flushNext('leave');
$animate.flushNext('enter');
$animate.flushNext('addClass');
$animate.flushNext('addClass');

Expand Down Expand Up @@ -220,6 +221,7 @@ describe('uiView', function () {
$q.flush();

expect($animate.flushNext('leave').element).toMatchText(hState.views.inner.template);
$animate.flushNext('enter');

var target = $animate.flushNext('addClass').element;
expect(target).toHaveClass('test');
Expand Down

0 comments on commit 83b6634

Please sign in to comment.