-
Notifications
You must be signed in to change notification settings - Fork 53
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
onScroll, onReachStart, onReachEnd callbacks #41
base: master
Are you sure you want to change the base?
Conversation
…s.animValues logic to fully control the component
@kwieccia I love these changes ❤ and the overall thinking here. I'm super busy right now, so I can't say when I'll merge this, but I certainly intend to. |
OK I had some time to dig into this. Some thoughts:
I like this. I'm fine this change, so long as we:
Regarding point #2, there are not many perf optimizations going on right now, so I'm cautious about doing more work on the scroll event listener. But I'm open to it.
We'll likely want to throttle these calls a bit. The UX of this is such that once you hit the end/start, you are almost always still scrolling, so this will likely result in a bunch of callbacks firing all at once. The throttle speed could maybe be another prop. |
Hi @hew, Thank you for the feedback! I finally found some time to make changes. 1. Provide a fallback 2. onReach callbacks performance |
Yeah I was pretty on-the-fence about the throttle prop. I'm totally cool to leave it as-is for now. Thanks for these contributions @kwieccia! I'll see what I can do about getting them merged in relatively soon. |
I implemented an infinite scroll with that, thanks for the PR |
@hew how's that merge going? |
@hew is 💀 rip |
I found react-scroll-horizontal very useful, but in my use case I needed some more control over the component and I wanted to run callbacks on reaching the scrolling area boundaries. I've made a few changes, that maybe you find reasonable enough to merge them to the repository.
This PR introduces
onScroll
,onReachStart
andonReachEnd
callbacks and changes also a little bit of existing logic, as described below.Controlling scroll position by a relative value seems a bit limited to me. My feeling is that if a component can be controlled from the parent level, it should be fully controlled by an absolute value (and return current position to
onScroll
callback). It gives possibility to set scroll position exactly where you want to (at the start, at the end, to some element). So I've changed thissetState
toanimValues: this.props.animValues
.However, I'm aware that this is kind of a "breaking change" and that scrolling by relative value may be good for some use cases. I'm thinking about keeping these two ways of controlling the scroll position maybe?
I'm not sure what was the purpose of
1
and+1
, but I discovered that if scroll position is controlled by theanimValues
property and you set limit values (0
, max), newly introducedonReachStart
andonReachEnd
(placed inresetMin
andresetMax
) wouldn't be called. I haven't noticed any issues after changing this part, but if I did some wrong here and should call these callbacks somewhere else, then please let me know.