Skip to content

Commit

Permalink
fix(refresher): ios native refresher now works in side menu (ionic-te…
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi authored and Takuma Kira committed Nov 13, 2020
1 parent 771b226 commit ca4ffc5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/src/components/refresher/refresher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class Refresher implements ComponentInterface {
private async setupiOSNativeRefresher(pullingSpinner: HTMLIonSpinnerElement, refreshingSpinner: HTMLIonSpinnerElement) {
this.elementToTransform = this.scrollEl!;
const ticks = pullingSpinner.shadowRoot!.querySelectorAll('svg');
const MAX_PULL = this.scrollEl!.clientHeight * 0.16;
let MAX_PULL = this.scrollEl!.clientHeight * 0.16;
const NUM_TICKS = ticks.length;

writeTask(() => ticks.forEach(el => el.style.setProperty('animation', 'none')));
Expand Down Expand Up @@ -251,6 +251,18 @@ export class Refresher implements ComponentInterface {
if (!this.didRefresh) {
translateElement(this.elementToTransform, '0px');
}

/**
* If the content had `display: none` when
* the refresher was initialized, its clientHeight
* will be 0. When the gesture starts, the content
* will be visible, so try to get the correct
* client height again. This is most common when
* using the refresher in an ion-menu.
*/
if (MAX_PULL === 0) {
MAX_PULL = this.scrollEl!.clientHeight * 0.16;
}
},
onMove: ev => {
this.lastVelocityY = ev.velocityY;
Expand Down

0 comments on commit ca4ffc5

Please sign in to comment.