fix(angular): no animate in browser nav

This commit is contained in:
Manu Mtz.-Almeida
2018-11-29 01:26:40 +01:00
committed by Manu MA
parent 194667c62a
commit 276c883493
3 changed files with 14 additions and 6 deletions

View File

@ -10,7 +10,8 @@ export class NavController {
private direction: NavDirection = DEFAULT_DIRECTION; private direction: NavDirection = DEFAULT_DIRECTION;
private animated = DEFAULT_ANIMATED; private animated = DEFAULT_ANIMATED;
private guessDirection: NavDirection = 'root'; private guessDirection: NavDirection = 'forward';
private guessAnimation = false;
private lastNavId = -1; private lastNavId = -1;
constructor( constructor(
@ -22,6 +23,7 @@ export class NavController {
router.events.subscribe(ev => { router.events.subscribe(ev => {
if (ev instanceof NavigationStart) { if (ev instanceof NavigationStart) {
const id = (ev.restoredState) ? ev.restoredState.navigationId : ev.id; const id = (ev.restoredState) ? ev.restoredState.navigationId : ev.id;
this.guessAnimation = !ev.restoredState;
this.guessDirection = id < this.lastNavId ? 'back' : 'forward'; this.guessDirection = id < this.lastNavId ? 'back' : 'forward';
this.lastNavId = this.guessDirection === 'forward' ? ev.id : id; this.lastNavId = this.guessDirection === 'forward' ? ev.id : id;
} }
@ -77,8 +79,8 @@ export class NavController {
if (this.direction === 'auto') { if (this.direction === 'auto') {
direction = this.guessDirection; direction = this.guessDirection;
console.log('guessed', direction); animated = this.guessAnimation;
animated = direction !== 'root'; console.debug('[nav-controller] guessed nav direction', direction, 'animated', animated);
} else { } else {
animated = this.animated; animated = this.animated;
direction = this.direction; direction = this.direction;

View File

@ -32,7 +32,12 @@ describe('router-link', () => {
await testForward(); await testForward();
}); });
it('should go forward with button + navigateForward', async () => { it('should go forward with button + navigateByUrl()', async () => {
await element(by.css('#button')).click();
await testForward();
});
it('should go forward with button + navigateForward()', async () => {
await element(by.css('#button-forward')).click(); await element(by.css('#button-forward')).click();
await testForward(); await testForward();
}); });

View File

@ -1,11 +1,12 @@
# Build core
pushd ../../.. pushd ../../..
# Build core
pushd core pushd core
npm run build npm run build
npm run link npm link
popd popd
# Build angular
pushd angular pushd angular
npm link @ionic/core npm link @ionic/core
npm run build npm run build