mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(packages): move the packages to root
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { Component, Listen, Method } from '@stencil/core';
|
||||
import { LoadingOptions, OverlayController } from '../../index';
|
||||
import { createOverlay, dismissOverlay, getTopOverlay, removeLastOverlay } from '../../utils/overlays';
|
||||
|
||||
|
||||
@Component({
|
||||
tag: 'ion-loading-controller'
|
||||
})
|
||||
export class LoadingController implements OverlayController {
|
||||
|
||||
private loadings = new Map<number, HTMLIonLoadingElement>();
|
||||
|
||||
@Listen('body:ionLoadingWillPresent')
|
||||
protected loadingWillPresent(ev: any) {
|
||||
this.loadings.set(ev.target.overlayId, ev.target);
|
||||
}
|
||||
|
||||
@Listen('body:ionLoadingWillDismiss')
|
||||
@Listen('body:ionLoadingDidUnload')
|
||||
protected loadingWillDismiss(ev: any) {
|
||||
this.loadings.delete(ev.target.overlayId);
|
||||
}
|
||||
|
||||
@Listen('body:keyup.escape')
|
||||
protected escapeKeyUp() {
|
||||
removeLastOverlay(this.loadings);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a loading overlay with loading options.
|
||||
*/
|
||||
@Method()
|
||||
create(opts?: LoadingOptions): Promise<HTMLIonLoadingElement> {
|
||||
return createOverlay(document.createElement('ion-loading'), opts);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dismiss the open loading overlay.
|
||||
*/
|
||||
@Method()
|
||||
dismiss(data?: any, role?: string, loadingId = -1) {
|
||||
return dismissOverlay(data, role, this.loadings, loadingId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the most recently opened loading overlay.
|
||||
*/
|
||||
@Method()
|
||||
getTop(): HTMLIonLoadingElement {
|
||||
return getTopOverlay(this.loadings);
|
||||
}
|
||||
}
|
||||
38
core/src/components/loading-controller/readme.md
Normal file
38
core/src/components/loading-controller/readme.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# ion-loading-controller
|
||||
|
||||
Loading controllers programmatically control the loading component. Loadings can be created and dismissed from the loading controller. View the [Loading](../../loading/Loading) documentation for a full list of options to pass upon creation.
|
||||
|
||||
|
||||
```javascript
|
||||
async function presentLoading() {
|
||||
const loadingController = document.querySelector('ion-loading-controller');
|
||||
await loadingController.componentOnReady();
|
||||
|
||||
const loadingElement = await loadingController.create({
|
||||
content: 'Please wait...',
|
||||
spinner: 'crescent',
|
||||
duration: 2000
|
||||
});
|
||||
return await loadingElement.present();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
#### create()
|
||||
|
||||
|
||||
#### dismiss()
|
||||
|
||||
|
||||
#### getTop()
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
||||
Reference in New Issue
Block a user