mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
@ -156,6 +156,12 @@ export class MenuController {
|
|||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tempDisable(temporarilyDisable: boolean) {
|
||||||
|
this._menus.forEach(menu => {
|
||||||
|
menu.tempDisable(temporarilyDisable);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the menu. If it's closed, it will open, and if opened, it
|
* Toggle the menu. If it's closed, it will open, and if opened, it
|
||||||
* will close.
|
* will close.
|
||||||
|
@ -198,6 +198,7 @@ export class Menu extends Ion {
|
|||||||
private _isSwipeEnabled: boolean = true;
|
private _isSwipeEnabled: boolean = true;
|
||||||
private _isPers: boolean = false;
|
private _isPers: boolean = false;
|
||||||
private _init: boolean = false;
|
private _init: boolean = false;
|
||||||
|
private _prevEnabled: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -419,11 +420,11 @@ export class Menu extends Ion {
|
|||||||
*/
|
*/
|
||||||
swipeStart() {
|
swipeStart() {
|
||||||
// user started swiping the menu open/close
|
// user started swiping the menu open/close
|
||||||
if (this._isPrevented() || !this._isEnabled || !this._isSwipeEnabled) return;
|
if (this._isEnabled && this._isSwipeEnabled && !this._isPrevented()) {
|
||||||
|
|
||||||
this._before();
|
this._before();
|
||||||
this._getType().setProgressStart(this.isOpen);
|
this._getType().setProgressStart(this.isOpen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -451,9 +452,6 @@ export class Menu extends Ion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
private _before() {
|
private _before() {
|
||||||
// this places the menu into the correct location before it animates in
|
// this places the menu into the correct location before it animates in
|
||||||
// this css class doesn't actually kick off any animations
|
// this css class doesn't actually kick off any animations
|
||||||
@ -466,9 +464,6 @@ export class Menu extends Ion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
private _after(isOpen: boolean) {
|
private _after(isOpen: boolean) {
|
||||||
// keep opening/closing the menu disabled for a touch more yet
|
// keep opening/closing the menu disabled for a touch more yet
|
||||||
// only add listeners/css if it's enabled and isOpen
|
// only add listeners/css if it's enabled and isOpen
|
||||||
@ -495,15 +490,24 @@ export class Menu extends Ion {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
tempDisable(temporarilyDisable: boolean) {
|
||||||
|
if (temporarilyDisable) {
|
||||||
|
this._prevEnabled = this._isEnabled;
|
||||||
|
this._getType().setProgessStep(0);
|
||||||
|
this.enable(false);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.enable(this._prevEnabled);
|
||||||
|
this._after(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _prevent() {
|
private _prevent() {
|
||||||
// used to prevent unwanted opening/closing after swiping open/close
|
// used to prevent unwanted opening/closing after swiping open/close
|
||||||
// or swiping open the menu while pressing down on the MenuToggle
|
// or swiping open the menu while pressing down on the MenuToggle
|
||||||
this._preventTime = Date.now() + 20;
|
this._preventTime = Date.now() + 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
private _isPrevented() {
|
private _isPrevented() {
|
||||||
return this._preventTime > Date.now();
|
return this._preventTime > Date.now();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {App, IonicApp, MenuController, Page, NavController, Alert} from '../../../../../src';
|
import {ViewChild} from '@angular/core';
|
||||||
|
import {App, IonicApp, MenuController, Page, NavController, Alert, Nav} from '../../../../../src';
|
||||||
|
|
||||||
|
|
||||||
@Page({
|
@Page({
|
||||||
@ -16,6 +17,10 @@ class Page1 {
|
|||||||
});
|
});
|
||||||
this.nav.present(alert);
|
this.nav.present(alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goToPage2() {
|
||||||
|
this.nav.push(Page2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +45,7 @@ class E2EApp {
|
|||||||
rootPage;
|
rootPage;
|
||||||
changeDetectionCount: number = 0;
|
changeDetectionCount: number = 0;
|
||||||
pages: Array<{title: string, component: any}>;
|
pages: Array<{title: string, component: any}>;
|
||||||
|
@ViewChild(Nav) nav: Nav;
|
||||||
|
|
||||||
constructor(private app: IonicApp, private menu: MenuController) {
|
constructor(private app: IonicApp, private menu: MenuController) {
|
||||||
this.rootPage = Page1;
|
this.rootPage = Page1;
|
||||||
@ -54,8 +60,7 @@ class E2EApp {
|
|||||||
openPage(page) {
|
openPage(page) {
|
||||||
// Reset the content nav to have just this page
|
// Reset the content nav to have just this page
|
||||||
// we wouldn't want the back button to show in this scenario
|
// we wouldn't want the back button to show in this scenario
|
||||||
let nav = this.app.getComponent('nav');
|
this.nav.setRoot(page.component).then(() => {
|
||||||
nav.setRoot(page.component).then(() => {
|
|
||||||
// wait for the root page to be completely loaded
|
// wait for the root page to be completely loaded
|
||||||
// then close the menu
|
// then close the menu
|
||||||
this.menu.close();
|
this.menu.close();
|
||||||
|
@ -138,6 +138,6 @@
|
|||||||
|
|
||||||
</ion-menu>
|
</ion-menu>
|
||||||
|
|
||||||
<ion-nav id="nav" [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
|
<ion-nav id="nav" [root]="rootPage" #content></ion-nav>
|
||||||
|
|
||||||
<div [hidden]="isChangeDetecting()"></div>
|
<div [hidden]="isChangeDetecting()"></div>
|
@ -51,6 +51,10 @@
|
|||||||
<button (click)="presentAlert()">Open alert</button>
|
<button (click)="presentAlert()">Open alert</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<button (click)="goToPage2()">Go to Page 2</button>
|
||||||
|
</p>
|
||||||
|
|
||||||
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
<f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
@ -6,6 +6,7 @@ import {IonicApp} from '../app/app';
|
|||||||
import {Keyboard} from '../../util/keyboard';
|
import {Keyboard} from '../../util/keyboard';
|
||||||
import {NavParams} from './nav-params';
|
import {NavParams} from './nav-params';
|
||||||
import {pascalCaseToDashCase, isBlank} from '../../util/util';
|
import {pascalCaseToDashCase, isBlank} from '../../util/util';
|
||||||
|
import {MenuController} from '../menu/menu-controller';
|
||||||
import {NavPortal} from './nav-portal';
|
import {NavPortal} from './nav-portal';
|
||||||
import {SwipeBackGesture} from './swipe-back';
|
import {SwipeBackGesture} from './swipe-back';
|
||||||
import {Transition} from '../../transitions/transition';
|
import {Transition} from '../../transitions/transition';
|
||||||
@ -1555,7 +1556,8 @@ export class NavController extends Ion {
|
|||||||
edge: 'left',
|
edge: 'left',
|
||||||
threshold: this._sbThreshold
|
threshold: this._sbThreshold
|
||||||
};
|
};
|
||||||
this._sbGesture = new SwipeBackGesture(this.getNativeElement(), opts, this);
|
let menuCtrl = this._app.getAppInjector().get(MenuController);
|
||||||
|
this._sbGesture = new SwipeBackGesture(this.getNativeElement(), opts, this, menuCtrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.canSwipeBack()) {
|
if (this.canSwipeBack()) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import {MenuController} from '../menu/menu-controller';
|
||||||
import {NavController} from './nav-controller';
|
import {NavController} from './nav-controller';
|
||||||
import {SlideEdgeGesture} from '../../gestures/slide-edge-gesture';
|
import {SlideEdgeGesture} from '../../gestures/slide-edge-gesture';
|
||||||
import {SlideData} from '../../gestures/slide-gesture';
|
import {SlideData} from '../../gestures/slide-gesture';
|
||||||
@ -9,7 +10,8 @@ export class SwipeBackGesture extends SlideEdgeGesture {
|
|||||||
constructor(
|
constructor(
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
options: any,
|
options: any,
|
||||||
private _nav: NavController
|
private _nav: NavController,
|
||||||
|
private _menuCtrl: MenuController
|
||||||
) {
|
) {
|
||||||
super(element, assign({
|
super(element, assign({
|
||||||
direction: 'x',
|
direction: 'x',
|
||||||
@ -33,9 +35,11 @@ export class SwipeBackGesture extends SlideEdgeGesture {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSlideBeforeStart() {
|
onSlideBeforeStart(slideData: SlideData, ev: any) {
|
||||||
console.debug('swipeBack, onSlideBeforeStart');
|
console.debug('swipeBack, onSlideBeforeStart', ev.srcEvent.type);
|
||||||
this._nav.swipeBackStart();
|
this._nav.swipeBackStart();
|
||||||
|
|
||||||
|
this._menuCtrl.tempDisable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSlide(slide: SlideData) {
|
onSlide(slide: SlideData) {
|
||||||
@ -52,6 +56,8 @@ export class SwipeBackGesture extends SlideEdgeGesture {
|
|||||||
console.debug('swipeBack, onSlideEnd, shouldComplete', shouldComplete, 'currentStepValue', currentStepValue);
|
console.debug('swipeBack, onSlideEnd, shouldComplete', shouldComplete, 'currentStepValue', currentStepValue);
|
||||||
|
|
||||||
this._nav.swipeBackEnd(shouldComplete, currentStepValue);
|
this._nav.swipeBackEnd(shouldComplete, currentStepValue);
|
||||||
|
|
||||||
|
this._menuCtrl.tempDisable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user