Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionScroll events not firing on 2.3.0 #10938

Closed
joshuamorony opened this issue Mar 28, 2017 · 17 comments
Closed

ionScroll events not firing on 2.3.0 #10938

joshuamorony opened this issue Mar 28, 2017 · 17 comments
Assignees

Comments

@joshuamorony
Copy link

Ionic version: (check one with "x")
[ ] 1.x
[x ] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

When adding an event binding for ionScroll on ion-content it is never fired.

Expected behavior:

The Content component should fire scroll events when scrolled.

Steps to reproduce:

The following will work on 2.2.0 but not 2.3.0:

<ion-content (ionScroll)="doSomething()">

doSomething is never fired on 2.3.0.

@konrin
Copy link

konrin commented Mar 28, 2017

The same thing if you subscribe to an event from the code - the scrolling event does not fire!

this.content.ionScroll.subscribe((ev: ScrollEvent) => {})

@jjosef
Copy link

jjosef commented Mar 28, 2017

You need to call this.content.enableScrollListener() in the Component. Docs need update!

@peterpeterparker
Copy link
Contributor

peterpeterparker commented Mar 28, 2017

@jjosef mvp of the day, your solution works!

Except the doc which is not up-to-date, it's also "disturbing" that enableScrollListener is annotated as a private method in content.d.ts...

/**
 * @private
 */
enableScrollListener(): void;

@jjosef
Copy link

jjosef commented Mar 28, 2017

My instincts tell me this is a bug more than anything. Not sure why this method would be required before the listener is enabled. I'm too busy at the moment to look into it and submit a PR, but this was a quick fix..

@brandyscarney
Copy link
Member

It seems the code that was called in ngOnInit for content was moved to a function by this commit: 7e9bad5#diff-848174518abef5659a16d7dc15e82a62R374

Adding the following in content fixes it:

ngOnInit() {
  this.enableScrollListener();
}

cc @manucorporat

@dmastag
Copy link

dmastag commented Apr 5, 2017

It is still not working for me on ionic3 using iOS

@dmastag
Copy link

dmastag commented Apr 6, 2017

Wanted to share that I Got some advise from North McCormick on Slack to use wkwebview for the ion-infinte problem and it is working as a temporary workaround for that issue.

Sadly it is not working for this scroll event issue on a new ionic app i crated from scratch to test this

@dmastag
Copy link

dmastag commented Apr 7, 2017

@manucorporat I tried this using iPhone SE with and without wkwebview on 2.3.0 and 3.0.0 and 3.1.1
and it is still not working

@peterpeterparker
Copy link
Contributor

If I understand correctly, @dmastag it looks like @manucorporat fixed the scroll for UIWebView 2 days ago there #10936

@dmastag
Copy link

dmastag commented Apr 8, 2017

@peterpeterparker yeahh but on my test it only worked for ion infinite, and the onScroll was still not working

@manucorporat
Copy link
Contributor

manucorporat commented Apr 8, 2017

@dmastag this is a known limitation of UIWebView, and it is been there forever, the only thing you can do is to enableJSScroll() conditionally, but native scrolling is much smoother.
http://developer.telerik.com/featured/scroll-event-change-ios-8-big-deal/

The best chance if you depend on scrolling events is to start using WKWebView, in fact we have plans to deprecate UI very soon.

@shmulikmak
Copy link

Ionic does not know "enableScrollListener" in "this.content.enableScrollListener()"
he gave me error unkonw method/property..

@pawansingewar007
Copy link

Still not working in ionic 3.9

@maheshj11
Copy link

maheshj11 commented Feb 13, 2018

get the child ref using @ViewChild('scroll') scroll: any;
and then use the addScrollEventListener() on scroll to fire whenever the user scrolls
if you use this event inside the constructor and the event throws error or doesn't fire try using setTimeout:

setTimeout(() => {
  this.scroll.addScrollEventListener((e) => {
    console.log(e)
  })
}, 1000);

@aleksander351
Copy link

Try with something like this:

import { Renderer2 } from '@angular/core';
...
constructor(private renderer: Renderer2) {}

ngOnInit() {
    this.renderer.listen(this.specialComponent, 'scroll', (event) => {
        // Do something with 'event'
        console.log(this.specialComponent.scrollTop);
    });
}

@davidanaya
Copy link

So any idea if this is going to be fixed? I don't get any event fired when using ionScroll like
<ion-content (ionScroll)="scrollHandler($handler)">

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.