mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(refresher): refresher correctly detects native refresher when shown asynchronously (#22623)
resolves #22616
This commit is contained in:
@ -124,8 +124,8 @@ export class Refresher implements ComponentInterface {
|
||||
*/
|
||||
@Event() ionStart!: EventEmitter<void>;
|
||||
|
||||
private checkNativeRefresher() {
|
||||
const useNativeRefresher = shouldUseNativeRefresher(this.el, getIonMode(this));
|
||||
private async checkNativeRefresher() {
|
||||
const useNativeRefresher = await shouldUseNativeRefresher(this.el, getIonMode(this));
|
||||
if (useNativeRefresher && !this.nativeRefresher) {
|
||||
const contentEl = this.el.closest('ion-content');
|
||||
this.setupNativeRefresher(contentEl);
|
||||
@ -411,7 +411,7 @@ export class Refresher implements ComponentInterface {
|
||||
this.scrollEl = await contentEl.getScrollElement();
|
||||
this.backgroundContentEl = getElementRoot(contentEl).querySelector('#background-content') as HTMLElement;
|
||||
|
||||
if (shouldUseNativeRefresher(this.el, getIonMode(this))) {
|
||||
if (await shouldUseNativeRefresher(this.el, getIonMode(this))) {
|
||||
this.setupNativeRefresher(contentEl);
|
||||
} else {
|
||||
this.gesture = (await import('../../utils/gesture')).createGesture({
|
||||
|
@ -166,9 +166,14 @@ export const translateElement = (el?: HTMLElement, value?: string) => {
|
||||
// Utils
|
||||
// -----------------------------
|
||||
|
||||
export const shouldUseNativeRefresher = (referenceEl: HTMLIonRefresherElement, mode: string) => {
|
||||
const pullingSpinner = referenceEl.querySelector('ion-refresher-content .refresher-pulling ion-spinner');
|
||||
const refreshingSpinner = referenceEl.querySelector('ion-refresher-content .refresher-refreshing ion-spinner');
|
||||
export const shouldUseNativeRefresher = async (referenceEl: HTMLIonRefresherElement, mode: string) => {
|
||||
const refresherContent = referenceEl.querySelector('ion-refresher-content');
|
||||
if (!refresherContent) { return Promise.resolve(false); }
|
||||
|
||||
await refresherContent.componentOnReady();
|
||||
|
||||
const pullingSpinner = refresherContent.querySelector('.refresher-pulling ion-spinner');
|
||||
const refreshingSpinner = refresherContent.querySelector('.refresher-refreshing ion-spinner');
|
||||
|
||||
return (
|
||||
pullingSpinner !== null &&
|
||||
|
Reference in New Issue
Block a user