Ionic 2 rc4 addScrollListener


#1

hi,

I have the code like

  @ViewChild(Content) content: Content;
...
   this.content.addScrollListener((event) => {
...

installed 2.0.0-rc.3-201612122136 which in my mind is predecessor of rc4, and now it stopped working

how it should be written for upcoming rc4?


#2

Oh dude, You scared me. I thought this was the actual RC4 lol.


#3

I believe it stays the same


#4

no, in current build there is no addScrollListener for Content.
Just check documentation.


#5

you also can check sources


#6

+1 ( Property ‘addScrollListener’ does not exist on type ‘Content’.)


#7

In RC.4 you could do:

content.ionScroll.subscribe(($event: any) => {
}

where content is content: Content


Alternative for content.addScrollEventListener in RC4
Replacement for ‘addScrollListener’?
#8

seems like your solution works, but I still can’t port my code to rc4, it hangs


#9

what hangs? do you have another issue open on the forum?


#10

Got the same problem. It works with this solution.


#11

Sorry for the late reply.

My app hanging, should debug this deeper, but decided to move forward with rc3, and update only after Ionic release, because every rc update takes 2-3 days of development just to fix stuff.


#12

I should say for me, this time at least, the update from RC.3 to RC.4 took like max a half day, but of course, depends of the app


#13

changing the code took 10 minutes, but app just hangs in random plase, so debug will take disabling all components and turning them one by one, too much for simple useless switch.
Better to wait until release.


#14

I could understand that, good luck


#15

@theromis hi , have you found a work around this…addScrollListener in RC 4


#16

I’m not sure if this helps, but it worked fine in my app:

            this.content.ionScroll.subscribe(($event) => {
                this.scrollAmount = $event.scrollTop;
            });

Scrolling event in ion-content
#17

yes, subscribe works perfect


#18

You are my HERO,
Working fine.

Thanks.