Skip to content

Commit cc4a479

Browse files
authored
Merge pull request #734 from GetStream/scrolled-up-threshold-prop
Add scrolledUpThreshold MessageList prop
2 parents ace31c9 + 2db141d commit cc4a479

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/components/MessageList/MessageList.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class MessageList extends PureComponent {
166166
this.setState({ newMessagesNotification: false });
167167
};
168168

169-
userScrolledUp = () => this.scrollOffset > 200;
169+
userScrolledUp = () => this.scrollOffset > this.props.scrolledUpThreshold;
170170

171171
listenToScroll = (offset, reverseOffset, threshold) => {
172172
this.scrollOffset = offset;
@@ -455,6 +455,8 @@ MessageList.propTypes = {
455455
* The user roles allowed to pin messages in various channel types
456456
*/
457457
pinPermissions: /** @type {PropTypes.Validator<import('types').PinPermissions>>} */ (PropTypes.object),
458+
/** The pixel threshold to determine whether or not the user is scrolled up in the list */
459+
scrolledUpThreshold: PropTypes.number,
458460
};
459461

460462
MessageList.defaultProps = {
@@ -471,6 +473,7 @@ MessageList.defaultProps = {
471473
noGroupByUser: false,
472474
messageActions: Object.keys(MESSAGE_ACTIONS),
473475
pinPermissions: defaultPinPermissions,
476+
scrolledUpThreshold: 200,
474477
};
475478

476479
export default withTranslationContext((props) => (

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ export interface MessageListProps {
673673
e: React.MouseEvent,
674674
mentioned_users: Client.UserResponse[],
675675
): void;
676+
scrolledUpThreshold?: number;
676677
}
677678

678679
export interface ChannelHeaderProps {

0 commit comments

Comments
 (0)