# "On-scroll" not working in \<ion-content\>

**URL:** <https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041>\
**Category:** ionic-v3\
**Created:** [January 25, 2016, 6:46pm UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041 "2016-01-25T18:46:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![prolink007](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/prolink007/32/93738_2.png) [@prolink007](https://forum.ionicframework.com/u/prolink007)\
**Post date:** [January 25, 2016, 6:46pm UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/1 "2016-01-25T18:46:53Z")

</div>

I am trying to use the “on-scroll” feature of “ion-content”. “on-scoll” is not working.

```
Page.html
<ion-content on-scroll="onPageScroll()">
</ion-content>

Page.ts
private onPageScroll(): void {
    console.log("testing this");
}

```

I serve this to chrome. When i scroll the page, nothing happens. Nothing is printed to console.

What am i doing wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![brandyshea](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/brandyshea/32/148286_2.png) [@brandyshea](https://forum.ionicframework.com/u/brandyshea)\
**Post date:** [January 25, 2016, 7:14pm UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/2 "2016-01-25T19:14:27Z")

</div>

The current way to do it is like this:

HTML:

```auto
<ion-content id="my-content">

```

JS:

```auto
// Need to wait until the component has been initialized
ngAfterViewInit() {
 // Here 'my-content' is the ID of my ion-content
 this.content = this.app.getComponent('my-content');
 this.content.addScrollEventListener(this.onPageScroll);
}

onPageScroll() {
  console.log('They see me scrolling...');
}

```

Where did you see an `on-scroll` attribute?

> **[Ionic Framework](https://ionicframework.com/docs/api/components/content/Content/)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

---

<div class="post-metadata">

**Author:** ![prolink007](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/prolink007/32/93738_2.png) [@prolink007](https://forum.ionicframework.com/u/prolink007)\
**Post date:** [January 25, 2016, 8:12pm UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/3 "2016-01-25T20:12:03Z")

</div>

Thanks Brandy, i actually just saw that on the [Content](http://ionicframework.com/docs/v2/2.0.0-alpha.42/api/components/content/Content/)documentation. Implemented it already and came back here to give the answer.

---

<div class="post-metadata">

**Author:** ![warnerpinz](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@warnerpinz](https://forum.ionicframework.com/u/warnerpinz)\
**Post date:** [April 3, 2016, 5:12am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/4 "2016-04-03T05:12:02Z")

</div>

@brandyshea, what is the datatype of the “this.content”? I’m using typescript, and I get an error:  
app.bundle.js:431 Uncaught (in promise) TypeError: this.content.addScrollEventListener is not a function(…)

---

<div class="post-metadata">

**Author:** ![vandelay](https://avatars.discourse-cdn.com/v4/letter/v/278dde/32.png) [@vandelay](https://forum.ionicframework.com/u/vandelay)\
**Post date:** [April 6, 2016, 8:58am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/5 "2016-04-06T08:58:41Z")

</div>

use addScrollListener instead of addScrollEventListener

---

<div class="post-metadata">

**Author:** ![maciejkoch](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/maciejkoch/32/99483_2.png) [@maciejkoch](https://forum.ionicframework.com/u/maciejkoch)\
**Post date:** [April 6, 2016, 11:35am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/6 "2016-04-06T11:35:53Z")

</div>

How to get current scrollTop value with this solution?

ANSWER:

```
onPageScroll(event) {
  console.log(event.target.scrollTop);
}
```

---

<div class="post-metadata">

**Author:** ![filipsuk](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@filipsuk](https://forum.ionicframework.com/u/filipsuk)\
**Post date:** [July 24, 2016, 9:30am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/7 "2016-07-24T09:30:03Z")

</div>

Thanks for the hint @brandyshea. I have a problem detecting iOS momentum. I need to fire events during the scroll (user removes the finger, but momentum is still scrolling). Event fires at the end of momentum. Do you have any solution for this? Thank you

---

<div class="post-metadata">

**Author:** ![dmastag](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dmastag/32/104373_2.png) [@dmastag](https://forum.ionicframework.com/u/dmastag)\
**Post date:** [August 21, 2016, 4:57pm UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/8 "2016-08-21T16:57:29Z")

</div>

How but adding a delay on the callback?

---

<div class="post-metadata">

**Author:** ![rafaelbuiu](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rafaelbuiu/32/102240_2.png) [@rafaelbuiu](https://forum.ionicframework.com/u/rafaelbuiu)\
**Post date:** [September 6, 2016, 11:11am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/9 "2016-09-06T11:11:30Z")

</div>

Hi filipsuk!  
Have you found the solution for this?  
I have to track each scrolled pixel but this momentum thing is killing me.

---

<div class="post-metadata">

**Author:** ![maith123](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@maith123](https://forum.ionicframework.com/u/maith123)\
**Post date:** [March 1, 2017, 1:11am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/10 "2017-03-01T01:11:55Z")

</div>

> [@filipsuk](#):
>
> till scrolling)

any luck??? i need help too

---

<div class="post-metadata">

**Author:** ![filipsuk](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@filipsuk](https://forum.ionicframework.com/u/filipsuk)\
**Post date:** [March 8, 2017, 8:25am UTC](https://forum.ionicframework.com/t/on-scroll-not-working-in-ion-content/42041/11 "2017-03-08T08:25:16Z")

</div>

@rafaelbuiu @maith123 Unfortunately, I don’t have a solution yet 😕 you can however try this [How to bind a function to the onScroll event?](https://forum.ionicframework.com/t/how-to-bind-a-function-to-the-onscroll-event/52416/7?u=filipsuk)
