Skip to content

Commit 83b6634

Browse files
committed
fix(uiView): don't animate initial load
1 parent a402415 commit 83b6634

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/viewDirective.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
9494
if (viewIsUpdating) return;
9595
viewIsUpdating = true;
9696

97-
try { updateView(); } catch (e) {
97+
try { updateView(true); } catch (e) {
9898
viewIsUpdating = false;
9999
throw e;
100100
}
@@ -104,7 +104,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
104104
$scope.$on('$stateChangeSuccess', eventHook);
105105
$scope.$on('$viewContentLoading', eventHook);
106106

107-
updateView();
107+
updateView(false);
108108

109109
function cleanupLastView() {
110110
if (currentEl) {
@@ -118,7 +118,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $ui
118118
}
119119
}
120120

121-
function updateView() {
121+
function updateView(shouldAnimate) {
122122
var locals = $state.$current && $state.$current.locals[name];
123123

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

135135
currentScope = $scope.$new();
136136
$compile(currentEl.contents())(currentScope);

test/viewDirectiveSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ describe('uiView', function () {
191191

192192
$animate.flushNext('enter');
193193
$animate.flushNext('leave');
194+
$animate.flushNext('enter');
194195
$animate.flushNext('addClass');
195196
$animate.flushNext('addClass');
196197

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

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

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

0 commit comments

Comments
 (0)