Skip to content

Commit a693c99

Browse files
add onScrolledFromBottom prop
1 parent fe8f5d6 commit a693c99

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ The `autoscroll` higher-order-component supports the followig props
7777
|-|-|-|
7878
|OnScrolled|`undefined`|called without arguments whenever the list is scrolled|
7979
|OnScrolledTop|`undefined`|called without arguments whenever the list is scrolled to the top|
80+
|onScrolledFromBottom|`undefined`|called when the list that is currently scrolled to the bottom is scrolled up|
8081

8182
## options
8283

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ export default (Component, { isScrolledDownThreshold = 150 } = { }) => class ext
2929
}
3030
}
3131
handleScroll(e){
32-
this._isScrolledDown = isScrolledDown(this._el, isScrolledDownThreshold)
32+
const nextIsScrolledDown = isScrolledDown(this._el, isScrolledDownThreshold);
33+
if (!nextIsScrolledDown && this._isScrolledDown) {
34+
this.props.onScrolledFromBottom && this.props.onScrolledFromBottom(e);
35+
}
36+
this._isScrolledDown = nextIsScrolledDown;
37+
3338
if(isScrolledUp(this._el)){
3439
this.props.onScrolledTop && this.props.onScrolledTop(e)
3540
}
41+
3642
this.props.onScrolled && this.props.onScrolled(e)
3743
}
3844
componentDidMount(){
@@ -53,11 +59,11 @@ export default (Component, { isScrolledDownThreshold = 150 } = { }) => class ext
5359
else this.scrollDownIfNeeded()
5460
}
5561
render(){
56-
const { onScrolled, onScrolledTop, ...rest } = this.props
62+
const { onScrolled, onScrolledTop, onScrolledFromBottom, ...rest } = this.props
5763
return <Component
5864
{...rest}
5965
ref={ el => this._el = ReactDOM.findDOMNode(el) }
6066
onScroll={ e => this.handleScroll(e) }
6167
/>
6268
}
63-
}
69+
}

0 commit comments

Comments
 (0)