mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
refactor(): deprecate web component controllers (#19109)
This commit is contained in:
@ -2,10 +2,11 @@ import { Build, Component, ComponentInterface, Element, Event, EventEmitter, Hos
|
||||
|
||||
import { config } from '../../global/config';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import { Gesture, GestureDetail, IonicAnimation, MenuChangeEventDetail, MenuControllerI, MenuI, Side } from '../../interface';
|
||||
import { Gesture, GestureDetail, IonicAnimation, MenuChangeEventDetail, MenuI, Side } from '../../interface';
|
||||
import { Point, getTimeGivenProgression } from '../../utils/animation/cubic-bezier';
|
||||
import { GESTURE_CONTROLLER } from '../../utils/gesture';
|
||||
import { assert, isEndSide as isEnd } from '../../utils/helpers';
|
||||
import { menuController } from '../../utils/menu-controller';
|
||||
|
||||
@Component({
|
||||
tag: 'ion-menu',
|
||||
@ -31,15 +32,12 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
backdropEl?: HTMLElement;
|
||||
menuInnerEl?: HTMLElement;
|
||||
contentEl?: HTMLElement;
|
||||
menuCtrl?: MenuControllerI;
|
||||
|
||||
@Element() el!: HTMLIonMenuElement;
|
||||
|
||||
@State() isPaneVisible = false;
|
||||
@State() isEndSide = false;
|
||||
|
||||
@Prop({ connect: 'ion-menu-controller' }) lazyMenuCtrl!: HTMLIonMenuControllerElement;
|
||||
|
||||
/**
|
||||
* The content's id the menu should use.
|
||||
*/
|
||||
@ -148,7 +146,6 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
return;
|
||||
}
|
||||
|
||||
const menuCtrl = this.menuCtrl = await this.lazyMenuCtrl.componentOnReady().then(p => p._getInstance());
|
||||
const el = this.el;
|
||||
const parent = el.parentNode as any;
|
||||
const content = this.contentId !== undefined
|
||||
@ -169,7 +166,7 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
this.sideChanged();
|
||||
|
||||
// register this menu with the app's menu controller
|
||||
menuCtrl!._register(this);
|
||||
menuController._register(this);
|
||||
|
||||
this.gesture = (await import('../../utils/gesture')).createGesture({
|
||||
el: document,
|
||||
@ -191,7 +188,7 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
|
||||
componentDidUnload() {
|
||||
this.blocker.destroy();
|
||||
this.menuCtrl!._unregister(this);
|
||||
menuController._unregister(this);
|
||||
if (this.animation) {
|
||||
this.animation.destroy();
|
||||
}
|
||||
@ -277,7 +274,7 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
*/
|
||||
@Method()
|
||||
setOpen(shouldOpen: boolean, animated = true): Promise<boolean> {
|
||||
return this.menuCtrl!._setOpen(this, shouldOpen, animated);
|
||||
return menuController._setOpen(this, shouldOpen, animated);
|
||||
}
|
||||
|
||||
async _setOpen(shouldOpen: boolean, animated = true): Promise<boolean> {
|
||||
@ -309,7 +306,10 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
this.animation = undefined;
|
||||
}
|
||||
// Create new animation
|
||||
this.animation = await this.menuCtrl!._createAnimation(this.type!, this);
|
||||
this.animation = await menuController._createAnimation(this.type!, this);
|
||||
if (!config.getBoolean('animated', true)) {
|
||||
this.animation.duration(0);
|
||||
}
|
||||
this.animation.fill('both');
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
if (this._isOpen) {
|
||||
return true;
|
||||
// TODO error
|
||||
} else if (this.menuCtrl!.getOpenSync()) {
|
||||
} else if (menuController._getOpenSync()) {
|
||||
return false;
|
||||
}
|
||||
return checkEdgeSide(
|
||||
@ -499,8 +499,8 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
this.forceClosing();
|
||||
}
|
||||
|
||||
if (!this.disabled && this.menuCtrl) {
|
||||
this.menuCtrl._setActiveMenu(this);
|
||||
if (!this.disabled) {
|
||||
menuController._setActiveMenu(this);
|
||||
}
|
||||
assert(!this.isAnimating, 'can not be animating');
|
||||
}
|
||||
|
Reference in New Issue
Block a user