Skip to content

container onScroll listen #77

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

Open
javaxiu opened this issue Mar 9, 2023 · 2 comments
Open

container onScroll listen #77

javaxiu opened this issue Mar 9, 2023 · 2 comments

Comments

@javaxiu
Copy link

javaxiu commented Mar 9, 2023

here is listening to the window scroll event, but what if the scroll area is a div not the window, it seems won't be able to work , especially onFetchMore . so... i am getting stuck in this issue

window.addEventListener('scroll', onScroll);

@vitorzerbeto
Copy link

You need to add the scroll event on the div that the react-simple-pull-to-refresh creates around your content. Something like this:

const ptr = document.querySelector(".pull_to_refresh .ptr__children");
ptr.addEventListener('scroll', onScroll)

@helzapps
Copy link

So the suggestion by @vitorzerbeto doesn't seem to work. I can get the querySelector to find what I believe is the appropriate div, but the 'scroll' event is never fired because I don't think it's actually scrolling anything. Based on the styles I'm seeing added to the .ptr__children div, they are applying a transform to that div such that it's not scrolling, but being offset as the user clicks and drags.
I'm in a situation where my child elements are divs with an onClick event that if my drag/scroll starts and ends inside of that div, then it's firing the onClick method when I don't think it should because the user was merely scrolling/click and dragging. Eventually, my project will be run inside of a native App wrapper, so the events will be touch down and drag, which is extensibly a scroll on mobile, and generally with native scroll views, the act of scrolling/dragging cancels out the event chain to propagate touch events to the children.
So I'm looking for a way to detect that click/drag event in order to perform a similar function of not passing on those events to the children whilst scrolling. Is there a way to do this with the component as is?

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

3 participants