I want to watch if is at the top position.
When I scroll down and scroll up, I cannot get right scroll top position.
This is my code.
<ion-content [scrollEvents]="true" (ionScroll)="onScroll($event)" (ionScrollEnd)="onScrollEnd()">
...
</ion-content>
@ViewChild(IonContent) content: IonContent;
onScroll($event: CustomEvent<ScrollDetail>) {
if ($event && $event.detail && $event.detail.scrollTop) {
const scrollTop = $event.detail.scrollTop;
console.log(scrollTop);
}
}
onScrollEnd() {
console.log(this.content, this.content['el']['scrollTop']);
}
home.page.ts:17 238
home.page.ts:17 173
home.page.ts:21 IonContent {el: ion-content.hydrated, ionScrollStart: Observable, ionScroll: Observable, ionScrollEnd: Observable}
When I scroll up to the top, (ionScroll)="...($event)" & $event.detail.scrollTop
does not give 0.
I think there may be some throttle(queue) to delay fire the event.
Does anyone know how to get 0 of scroll top position when it is on top? or any idea?