-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(useInfiniteScroll): using useInfiniteScroll with isInverse prop #2315
Open
rom-orlovich
wants to merge
6
commits into
alibaba:master
Choose a base branch
from
rom-orlovich:feat/use-infinite-scrolli-with-isinverse-prop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(useInfiniteScroll): using useInfiniteScroll with isInverse prop #2315
rom-orlovich
wants to merge
6
commits into
alibaba:master
from
rom-orlovich:feat/use-infinite-scrolli-with-isinverse-prop
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…down or up to get the data
rom-orlovich
changed the title
Feat/use infinite scrolli with isinverse prop
feat: use infinite scrolli with isinverse prop
Sep 5, 2023
rom-orlovich
changed the title
feat: use infinite scrolli with isinverse prop
feat(useInfiniteScroll): use infinite scrolli with isinverse prop
Sep 5, 2023
…to isReachBoundary
rom-orlovich
force-pushed
the
feat/use-infinite-scrolli-with-isinverse-prop
branch
from
September 5, 2023 19:16
09e3aea
to
f2e1deb
Compare
rom-orlovich
changed the title
feat(useInfiniteScroll): use infinite scrolli with isinverse prop
feat(useInfiniteScroll): using useInfiniteScroll with isInverse prop
Sep 6, 2023
Dubask
approved these changes
Sep 6, 2023
@hchlq 程哥有空看下这个哈~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
First and foremost, I want to express my deep appreciation for the ahooks project. It has been an invaluable addition to the React ecosystem, providing a collection of useful hooks that have played a significant role in helping the React community thrive.
💡 Background and solution
Problem and Scenario:
I've submitted this pull request to tackle a common challenge when implementing chat-like interfaces, where users often need to scroll upwards to load more messages or content. The problem arises because there is currently no built-in functionality to change the scroll direction and trigger the loading function.
Currently, without any props to modify the scroll direction, users must rotate the list and apply CSS tricks to simulate an upward scroll. This workaround is not intuitive and can lead to suboptimal user experiences.
Solution:
To improve this situation, I would suggest adding the capability to trigger the loading function when scrolling up, which aligns with common chat application behavior. I've implemented a straightforward logic to achieve this:
When a user scrolls up, the scrollTop value becomes negative relative to the container we monitor for scroll events.
If the sum of the negative scrollTop and the scroll height is less than or equal to the client height, and the chosen threshold is met, we can conclude that the user has scrolled to the top of the page.
At this point, we can trigger the load function, ensuring a smooth and familiar experience for users.
Final API Implementation:
As part of this pull request, I've introduced a new prop called isInverse to the useInfiniteScroll hook. When set to true, this prop specifies that the desired scroll direction should be upward. This allows developers to easily configure the scroll behavior to align with common chat application requirements, where users scroll up to load more messages or content.
📝 Changelog
☑️ Self Check before Merge