Skip to content

Commit 276c883

Browse files
committed
fix(angular): no animate in browser nav
1 parent 194667c commit 276c883

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

angular/src/providers/nav-controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export class NavController {
1010

1111
private direction: NavDirection = DEFAULT_DIRECTION;
1212
private animated = DEFAULT_ANIMATED;
13-
private guessDirection: NavDirection = 'root';
13+
private guessDirection: NavDirection = 'forward';
14+
private guessAnimation = false;
1415
private lastNavId = -1;
1516

1617
constructor(
@@ -22,6 +23,7 @@ export class NavController {
2223
router.events.subscribe(ev => {
2324
if (ev instanceof NavigationStart) {
2425
const id = (ev.restoredState) ? ev.restoredState.navigationId : ev.id;
26+
this.guessAnimation = !ev.restoredState;
2527
this.guessDirection = id < this.lastNavId ? 'back' : 'forward';
2628
this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
2729
}
@@ -77,8 +79,8 @@ export class NavController {
7779

7880
if (this.direction === 'auto') {
7981
direction = this.guessDirection;
80-
console.log('guessed', direction);
81-
animated = direction !== 'root';
82+
animated = this.guessAnimation;
83+
console.debug('[nav-controller] guessed nav direction', direction, 'animated', animated);
8284
} else {
8385
animated = this.animated;
8486
direction = this.direction;

angular/test/test-app/e2e/src/router-link.e2e-spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ describe('router-link', () => {
3232
await testForward();
3333
});
3434

35-
it('should go forward with button + navigateForward', async () => {
35+
it('should go forward with button + navigateByUrl()', async () => {
36+
await element(by.css('#button')).click();
37+
await testForward();
38+
});
39+
40+
it('should go forward with button + navigateForward()', async () => {
3641
await element(by.css('#button-forward')).click();
3742
await testForward();
3843
});

angular/test/test-app/scripts/build-ionic.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Build core
21
pushd ../../..
32

3+
# Build core
44
pushd core
55
npm run build
6-
npm run link
6+
npm link
77
popd
88

9+
# Build angular
910
pushd angular
1011
npm link @ionic/core
1112
npm run build

0 commit comments

Comments
 (0)