mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(all): component reusage (#18963)
Use new stencil APIs to allow ionic elements to be reused once removed from the DOM. fixes #18843 fixes #17344 fixes #16453 fixes #15879 fixes #15788 fixes #15484 fixes #17890 fixes #16364
This commit is contained in:
@ -97,20 +97,19 @@ export class Refresher implements ComponentInterface {
|
||||
*/
|
||||
@Event() ionStart!: EventEmitter<void>;
|
||||
|
||||
async componentDidLoad() {
|
||||
async connectedCallback() {
|
||||
if (this.el.getAttribute('slot') !== 'fixed') {
|
||||
console.error('Make sure you use: <ion-refresher slot="fixed">');
|
||||
return;
|
||||
}
|
||||
const contentEl = this.el.closest('ion-content');
|
||||
if (contentEl) {
|
||||
this.scrollEl = await contentEl.getScrollElement();
|
||||
} else {
|
||||
console.error('ion-refresher did not attach, make sure the parent is an ion-content.');
|
||||
if (!contentEl) {
|
||||
console.error('<ion-refresher> must be used inside an <ion-content>');
|
||||
return;
|
||||
}
|
||||
|
||||
this.scrollEl = await contentEl.getScrollElement();
|
||||
this.gesture = (await import('../../utils/gesture')).createGesture({
|
||||
el: this.el.closest('ion-content') as any,
|
||||
el: contentEl,
|
||||
gestureName: 'refresher',
|
||||
gesturePriority: 10,
|
||||
direction: 'y',
|
||||
@ -125,7 +124,7 @@ export class Refresher implements ComponentInterface {
|
||||
this.disabledChanged();
|
||||
}
|
||||
|
||||
componentDidUnload() {
|
||||
disconnectedCallback() {
|
||||
this.scrollEl = undefined;
|
||||
if (this.gesture) {
|
||||
this.gesture.destroy();
|
||||
|
||||
Reference in New Issue
Block a user