ionScroll event doesn't fire on ion-scroll


#1

On my page I have markup as below

<ion-content>
   <ion-scroll (ionScroll)="onPageScroll($event)" scrollY="true">
      long text here...... 
    </ion-scroll>
<.ion-content>

I then have a simple function onPageScroll to log out the scroll event

onPageScroll(e) { 
    console.log(e);
}

However the ionScroll event never seems to fire for the <ion-scroll> element

If I put the listener on <ion-content> it works without any problems. I’ve also tried removing <ion-content> from the page to see if there’s any conflict there be to no avail.

Does the ionScroll event not work on <ion-scroll> or is there a different way to listen to it?

Thanks


#2

Why do you have to use ion scroll?
Please try like following:

<ion-content (ionScroll)="onPageScroll($event)">
   
 long text here...... 
   
</ion-content>

#3

Unfortunately it’s not that simple as I have multiple scrollable areas in the one view and you can only have 1 , the docs says to use ion-scroll in this instance

There should only be one content in a single view component. If additional scrollable elements are need, use ionScroll.

tallprince
June 28
Why do you have to use ion scroll?
Please try like following:

> <ion-content (ionScroll)="onPageScroll($event)"> long text here...... </ion-content>

#4

what is your ionic version?


#5

I’m currently using ionic 3.4.2 . I’ve just tested ionic 3.5 now as well but no difference

Just to expand further, the reason I am using <ion-scroll> is because I am using <ion-slider>

In each slide I have text of varying length so a user needs to be able to scroll up and down it

Thanks


Unable to get scroll events in ion-scroll
#6

After checking out the source code I finally figured out how to attach a scroll listener

   this.scrollElement.addScrollEventListener((e) => {
      console.log(e);
    })

However it’s pretty useless as it seems like <ion-scroll> doesn’t have as much information available in it’s scroll event compared to <ion-content>

For example, there is no e.domWrite() or e.scrollTop which are two of things I need most!

Is there any plans to extend the <ion-scroll> scroll event to support these things?


#7

Hi @robertboland, any update on this? Have you figured it out?


#8

I wrote a palatative solution


#9

Not working for me. Here is the link stackoverflow link