Skip to content

Commit

Permalink
feat(message-list): added disableOnYReachWhenNoScroll property
Browse files Browse the repository at this point in the history
PerfectScrollbar by default fires onYReachStart and onYReachEnd events
even when there is no scrollbar at all.
"disableOnYReachWhenNoScroll" property disables this behavior.
  • Loading branch information
supersnager committed Apr 19, 2021
1 parent 4f67267 commit 3176f2e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/components/MessageList/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class MessageListInner extends React.Component {
onYReachStart,
onYReachEnd,
className,
disableOnYReachWhenNoScroll,
scrollBehavior, // Just to remove rest
autoScrollToBottom, // Just to remove rest
autoScrollToBottomOnMount, // Just to remove rest
Expand Down Expand Up @@ -285,6 +286,7 @@ class MessageListInner extends React.Component {
<PerfectScrollbar
onYReachStart={onYReachStart}
onYReachEnd={onYReachEnd}
onSync={(ps) => ps.update(disableOnYReachWhenNoScroll)}
className={`${cName}__scroll-wrapper`}
ref={this.scrollRef}
containerRef={(ref) => (this.containerRef.current = ref)}
Expand Down Expand Up @@ -371,6 +373,13 @@ MessageList.propTypes = {
*/
onYReachEnd: PropTypes.func,

/**
* Disables onYReachStart and onYReachEnd events from being fired<br />
* when the list is not scrollable.
* This is set to false by default for backward compatibility.
*/
disableOnYReachWhenNoScroll: PropTypes.func,

/**
* Auto scroll to bottom
*/
Expand All @@ -396,6 +405,7 @@ MessageList.defaultProps = {
loading: false,
loadingMore: false,
loadingMorePosition: "top",
disableOnYReachWhenNoScroll: false,
autoScrollToBottom: true,
autoScrollToBottomOnMount: true,
scrollBehavior: "auto",
Expand Down
35 changes: 27 additions & 8 deletions src/components/Scroll/perfect-scrollbar.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3176f2e

Please sign in to comment.