mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(isEnabled): do not disable during menu close
This commit is contained in:
@ -41,7 +41,7 @@ export class IonicApp {
|
|||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.overlays = [];
|
this.overlays = [];
|
||||||
this._enableTime = 0;
|
this._disableTime = 0;
|
||||||
|
|
||||||
// Our component registry map
|
// Our component registry map
|
||||||
this.components = {};
|
this.components = {};
|
||||||
@ -89,7 +89,7 @@ export class IonicApp {
|
|||||||
* something goes wrong during a transition and the app wasn't re-enabled correctly.
|
* something goes wrong during a transition and the app wasn't re-enabled correctly.
|
||||||
*/
|
*/
|
||||||
setEnabled(isEnabled, fallback=700) {
|
setEnabled(isEnabled, fallback=700) {
|
||||||
this._enableTime = (isEnabled ? 0 : Date.now() + fallback);
|
this._disableTime = (isEnabled ? 0 : Date.now() + fallback);
|
||||||
ClickBlock(!isEnabled, fallback + 100);
|
ClickBlock(!isEnabled, fallback + 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ export class IonicApp {
|
|||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
isEnabled() {
|
isEnabled() {
|
||||||
return (this._enableTime < Date.now());
|
return (this._disableTime < Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,6 @@ export class Menu extends Ion {
|
|||||||
this.getBackdropElement().classList.add('show-backdrop');
|
this.getBackdropElement().classList.add('show-backdrop');
|
||||||
|
|
||||||
this._disable();
|
this._disable();
|
||||||
this.app.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_after(isOpen) {
|
_after(isOpen) {
|
||||||
@ -165,18 +164,16 @@ export class Menu extends Ion {
|
|||||||
this.getNativeElement().classList.remove('show-menu');
|
this.getNativeElement().classList.remove('show-menu');
|
||||||
this.getBackdropElement().classList.remove('show-backdrop');
|
this.getBackdropElement().classList.remove('show-backdrop');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.app.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_disable() {
|
_disable() {
|
||||||
// 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 menu-toggle
|
// or swiping open the menu while pressing down on the menu-toggle
|
||||||
this._disableTime = Date.now();
|
this._disableTime = Date.now() + 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isDisabled() {
|
_isDisabled() {
|
||||||
return this._disableTime + 300 > Date.now();
|
return this._disableTime > Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +45,7 @@ export class ViewController extends Ion {
|
|||||||
this.id = ++ctrlIds;
|
this.id = ++ctrlIds;
|
||||||
this._ids = -1;
|
this._ids = -1;
|
||||||
this.zIndexes = -1;
|
this.zIndexes = -1;
|
||||||
|
this._disableTime = 0;
|
||||||
|
|
||||||
// build a new injector for child ViewItems to use
|
// build a new injector for child ViewItems to use
|
||||||
this.bindings = Injector.resolve([
|
this.bindings = Injector.resolve([
|
||||||
@ -531,7 +532,7 @@ export class ViewController extends Ion {
|
|||||||
// used to prevent unwanted transitions after JUST completing one
|
// used to prevent unwanted transitions after JUST completing one
|
||||||
// prevents the user from crazy clicking everything and possible flickers
|
// prevents the user from crazy clicking everything and possible flickers
|
||||||
// gives the app some time to cool off, slow down, and think about life
|
// gives the app some time to cool off, slow down, and think about life
|
||||||
this._enableTime = Date.now() + 100;
|
this._disableTime = Date.now() + 40;
|
||||||
|
|
||||||
// IonicApp global setEnabled to prevent other things from starting up
|
// IonicApp global setEnabled to prevent other things from starting up
|
||||||
this.app.setEnabled(isEnabled, fallback);
|
this.app.setEnabled(isEnabled, fallback);
|
||||||
@ -539,7 +540,7 @@ export class ViewController extends Ion {
|
|||||||
|
|
||||||
_isEnabled() {
|
_isEnabled() {
|
||||||
// used to prevent unwanted transitions after JUST completing one
|
// used to prevent unwanted transitions after JUST completing one
|
||||||
if (this._enableTime > Date.now()) {
|
if (this._disableTime > Date.now()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// IonicApp global isEnabled, maybe something else has the app disabled
|
// IonicApp global isEnabled, maybe something else has the app disabled
|
||||||
|
Reference in New Issue
Block a user