Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(Nav): fixes swipeBackEnabled as attribute
closes #5653
  • Loading branch information
manucorporat committed Mar 18, 2016
1 parent 7b1d7aa commit 17c3886
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion demos/events/main.html
Expand Up @@ -24,4 +24,4 @@
</ion-menu>


<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion demos/id/main.html
Expand Up @@ -31,4 +31,4 @@

</ion-menu>

<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion demos/menu/main.html
Expand Up @@ -31,4 +31,4 @@

</ion-menu>

<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/basic/main.html
Expand Up @@ -138,6 +138,6 @@

</ion-menu>

<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

<div [hidden]="isChangeDetecting()"></div>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/disable-swipe/main.html
Expand Up @@ -33,4 +33,4 @@

</ion-menu>

<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/enable-disable/main.html
Expand Up @@ -76,4 +76,4 @@
</ion-menu>


<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/multiple/main.html
Expand Up @@ -33,4 +33,4 @@
</ion-menu>


<ion-nav [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/overlay/main.html
Expand Up @@ -37,4 +37,4 @@
</ion-menu>


<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/push/main.html
Expand Up @@ -37,4 +37,4 @@
</ion-menu>


<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
2 changes: 1 addition & 1 deletion ionic/components/menu/test/reveal/main.html
Expand Up @@ -36,4 +36,4 @@

</ion-menu>

<ion-nav id="nav" [root]="rootView" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="nav" [root]="rootView" #content swipeBackEnabled="false"></ion-nav>
20 changes: 4 additions & 16 deletions ionic/components/nav/nav-controller.ts
Expand Up @@ -108,9 +108,9 @@ export class NavController extends Ion {
private _init = false;
private _trans: Transition;
private _sbGesture: SwipeBackGesture;
private _sbEnabled: boolean;
private _sbThreshold: number;

protected _sbEnabled: boolean;
protected _ids: number = -1;
protected _trnsDelay: any;
protected _trnsTime: number = 0;
Expand Down Expand Up @@ -1288,7 +1288,7 @@ export class NavController extends Ion {
let shouldResetZIndex = this._views.some(v => v.zIndex < 0);
if (shouldResetZIndex) {
this._views.forEach(view => {
view.setZIndex( view.zIndex + INIT_ZINDEX + 1, this._renderer );
view.setZIndex(view.zIndex + INIT_ZINDEX + 1, this._renderer);
});
}
}
Expand Down Expand Up @@ -1401,7 +1401,7 @@ export class NavController extends Ion {
// start the transition, fire callback when done...
this._transition(enteringView, leavingView, opts, (hasCompleted: boolean) => {
// swipe back has finished!!
console.debug('swipeBack, hasCompleted', hasCompleted);
console.debug('swipeBack, hasCompleted', hasCompleted);
});
}
}
Expand Down Expand Up @@ -1465,18 +1465,6 @@ export class NavController extends Ion {
}
}

/**
* @input {boolean} Whether it's possible to swipe-to-go-back on this nav controller or not.
*/
@Input()
get swipeBackEnabled(): boolean {
return this._sbEnabled;
}

set swipeBackEnabled(val: boolean) {
this._sbEnabled = isTrueProperty(val);
}

/**
* If it's possible to use swipe back or not. If it's not possible
* to go back, or swipe back is not enable then this will return false.
Expand Down Expand Up @@ -1572,7 +1560,7 @@ export class NavController extends Ion {
* @returns {viewController}
*/
getPrevious(view: ViewController): ViewController {
return this.getByIndex( this.indexOf(view) - 1 );
return this.getByIndex(this.indexOf(view) - 1);
}

/**
Expand Down
17 changes: 15 additions & 2 deletions ionic/components/nav/nav.ts
Expand Up @@ -3,6 +3,7 @@ import {Component, ElementRef, Input, Optional, NgZone, Compiler, AppViewManager
import {IonicApp} from '../app/app';
import {Config} from '../../config/config';
import {Keyboard} from '../../util/keyboard';
import {isTrueProperty} from '../../util/util';
import {NavController} from './nav-controller';
import {ViewController} from './view-controller';

Expand Down Expand Up @@ -42,10 +43,10 @@ import {ViewController} from './view-controller';
* Nav will automatically add a back button to it if there is a page
* before the one you are navigating to in the navigation stack.
*
* Additionally, specifying the `swipe-back-enabled` property will allow you to
* Additionally, specifying the `swipeBackEnabled` property will allow you to
* swipe to go back:
* ```html
* <ion-nav swipe-back-enabled="false" [root]="rootPage"></ion-nav>
* <ion-nav swipeBackEnabled="false" [root]="rootPage"></ion-nav>
* ```
*
* Here is a diagram of how Nav animates smoothly between pages:
Expand Down Expand Up @@ -146,6 +147,18 @@ export class Nav extends NavController {
}
}

/**
* @input {boolean} Whether it's possible to swipe-to-go-back on this nav controller or not.
*/
@Input()
get swipeBackEnabled(): boolean {
return this._sbEnabled;
}

set swipeBackEnabled(val: boolean) {
this._sbEnabled = isTrueProperty(val);
}

/**
* @private
*/
Expand Down
4 changes: 2 additions & 2 deletions ionic/components/nav/test/nested/index.ts
Expand Up @@ -44,7 +44,7 @@ export class Login {
</ion-content>
</ion-menu>
<ion-nav id="account-nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
<ion-nav id="account-nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
`
})
export class Account {
Expand Down Expand Up @@ -135,7 +135,7 @@ export class Profile {


@App({
template: `<ion-nav id="root-nav" [root]="rootPage" swipe-back-enabled="false"></ion-nav>`
template: `<ion-nav id="root-nav" [root]="rootPage" swipeBackEnabled="false"></ion-nav>`
})
class E2EApp {
constructor() {
Expand Down

0 comments on commit 17c3886

Please sign in to comment.