-
Notifications
You must be signed in to change notification settings - Fork 224
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
Takes a long time for onScroll to fire #198
Comments
please share a plunkr that reproduce it. |
I experience this as well. But this does not have to do with the firing of It's weird because the lengthy request only happens because it was triggered by this directive, and will never take that long if you do the HTTP call another way, for instance with a button click. |
this infinite scroll is an extract from http://echoesplayer.com - where it works pretty well. |
I experience the same problem as @ghost (the original author): whatever (@lansana I think you don't have the exact same problem.) Clue 1: When using Clue 2: Completely removing the throttle in code removes the problem: --- node_modules/ngx-infinite-scroll/modules/ngx-infinite-scroll.es5.js
+++ node_modules/ngx-infinite-scroll/modules/ngx-infinite-scroll.es5.js
@@ -311,7 +311,9 @@
*/
function attachScrollEvent(options) {
return Observable.fromEvent(options.container, 'scroll')
- .sampleTime(options.throttleDuration)
+ .do(event => console.warn('received event: ' + event))
.filter(options.filterBefore)
.mergeMap(function (ev) { return Observable.of(options.mergeMap(ev)); })
.subscribe(options.scrollHandler); Clue 3: I tried replacing I tried reproducing the problem using the demo plunker, but couldn't (I even changed versions to use latest software, i.e. Angular 5.0.3, rxjs 5.2.2 and Typescript 2.4.2). |
without a demo for this bug - it's hard to pinpoint the cause. |
Hi @orizens, thanks for following this up.
I agree, and I'm sad I couldn't reproduce this in a plunker although I spent 30 min trying. I guess it's related to other dependencies in my project. I tried various versions of Angular, RxJS, Typescript and ngx-infinite-scroll.
Of course! I even tried 0. The only thing that works is really removing the call to I also noticed that replacing |
it sounds like something in your app its out of zone and enters back after some processing. |
Hey Oren, I'm not sure about that, because
function attachScrollEvent(options) {
return Observable.fromEvent(options.container, 'scroll')
+ .do(event => console.warn('I am displayed instantaneously'))
.sampleTime(10)
+ .do(event => console.warn('I am displayed after 2 seconds'))
.filter(options.filterBefore) Another "funny" thing: the problem only happens with a mouse or trackpad. When using keyboard buttons (page down, end, arrows), all |
interesting - we need to find the cause, as sampleTime does work as expected for other use cases. |
all - please try latest 0.8.0. |
I experienced this issue also in Chrome (OS X), but not in other browsers. Happens still with new 0.8.1. It seems that the problematic part is the sampleTime() as adrienverge found out above. I think the root cause might be this: https://bugs.chromium.org/p/chromium/issues/detail?id=661155 sampleTime() uses timeout and while scrolling - especially rapidly with track pad - the events won't arrive. After the scrolling is stopped, it takes couple of seconds and everything is working again. I wonder if the semantics of the scroll throttle option could be changed a bit, so that 0 would leave the sampleTime() part out totally? |
you can tryout zero now. |
Bug still present with versions 0.8.0 and 0.8.1, with or without The problem still lies in the call to
|
@orizens maybe if options.throttle 0 or null return without sampleTime? |
@orizens I have to admit I'm not sure why you closed this issue. This is a real bug that directly impacts the functionality of your library in the most used browser by market share by far. I just thought your library didn't work properly as I always develop in chrome then checked out the infinite scrolling of my app in safari and was surprised to see it works fine. I understand this is open source and other people can contribute solutions but at least keep the issue open until fixed! |
@jcroll does zero helps? |
@orizens yes, zero not helps. |
Thanks @orizens. No the zero doesn't help, I believe some of the devs in this thread are closing in on the issue tho. |
Experience same issue. Same HTTP requests that can 30ms, take 2.3 seconds :( |
@orizens Hi guys, I've faced the same trouble :( Any estimation when it can be fixed? Thanks! |
Multiple users (including me) report a problem: the scroll function callback is called many seconds after it should be. It's not clear if the problem comes from `ngx-infinite-scroll` or another library (`RxJS`?). However, there's a simple fix for this problem. Let's apply it! Fixes orizens#198
Multiple users (including me) report a problem: the scroll function callback is called many seconds after it should be. It's not clear if the problem comes from `ngx-infinite-scroll` or another library (`RxJS`?). However, there's a simple fix that allows solving the bug by using `infiniteScrollThrottle="0"`. Let's apply it! Fixes orizens#198
I have opened #235, it solves the problem for me when using |
Same here. Using |
@adrienverge thanks - looking at your pr. |
@orizens thanks! |
version 0.8.3 released |
Issue still exists with last version of Chrome and even with |
Thanks to this post, it seems I solved the issue. I added a
No more slow http request. |
I have been struggling a lot with this, without knowing it was related to this library or this issue. I am using Angular Elements, and it was behaving properly during the development. When I finished the component, bundled, and started using in my website, it would not scroll. I thought it was something about angular, about angular elements, about me missing something about how events work with elements, etc. Two days later, after testing with my own scroll listener and realizing mine would work, I commented out the lines of I also did an experiment of replacing the I also think this issue should not have been closed, or at least the default value for |
I have
When I scroll to the bottom, it somtimes takes 4 seconds for onScroll to fire.
I've tried all kinds of values for infiniteScrollDistance. With a high value, it works initially, but after scrolling for a while, the problem is back.
The text was updated successfully, but these errors were encountered: