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

ScrolledUp Event issue #373

Open
poddarkhushbu07 opened this issue Dec 21, 2020 · 4 comments
Open

ScrolledUp Event issue #373

poddarkhushbu07 opened this issue Dec 21, 2020 · 4 comments

Comments

@poddarkhushbu07
Copy link

poddarkhushbu07 commented Dec 21, 2020

Expected Behaviour

scrolledUp should be triggered when scroll reaches the top of container.

Actual Behavior

I am using
ngx-infinite-scroll for my chat module. I want an event when scrollbar is at top of the container. For this, scrolledUp output event is present, but in my case it is not getting triggered on currentScrollPosition:0 . It is triggered after scrollbar is scrolled down a bit after reaching top position. i.e. currentScrollPosition:2 / currentScrollPosition:3.

infiniteScrollUpDistance:9.9
infiniteScrollThrottle: 1000
chatScrollDistance: 0

Version used: ^10.0.0
Browser Name and version: Chrome

@BarkhatovN
Copy link

I have same problem

@BarkhatovN
Copy link

BarkhatovN commented Jan 30, 2021

There are 2 points We should look for

ngx-infinite-scroll uses throttleTime with default configuration (leading value emits) so if you scroll to top in throttled interval, it will emit only first value, that could not satisfy infiniteScrollUpDistance check

For example, infiniteScrollUpDistance=2(scrollTop should be less then 20% of scrollHeight to emit event), scrollTop= 1000 scrollHeight=2000, throttle interval=500ms. If you scroll to top in that interval, only scrollTop=999 might be handled, so needed event wouldn't be emitted

Also It has problem with browser behaviour.
When scrollTop=0 and scrollHeight changes it doesn't change scrollTop, so we need scroll programmatically before add new elements (to scroll top 1 as Example) to let browser change scrollTop (navigate us to last shown element) when we add some elements in container

@orizens
Copy link
Owner

orizens commented Mar 26, 2022

please try latest v13

@mi-wit
Copy link

mi-wit commented Jun 24, 2022

I have the same issue (^13.0.2). It is also present in Chromium browser, but less often

My solution:
Make the scrollable list always 'scrolled down a bit':

  • add empty div with fixed height that is always on top of the scrolled list
  • set the 'snap-start' CSS property to the scrolled list and 'scroll-snap-type: y' to infinite-scroll

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants