Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

Ionic 4: How to get ion-content scrollTop

$
0
0

@thruthesky wrote:

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?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>