Skip to content

Commit

Permalink
Merge branch 'belsberry-on-scroll-event'
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Feb 2, 2016
2 parents 9cbb2a1 + a373297 commit f356c16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/basic/js/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class App extends React.Component{
this.setState({itemsCount: this.state.itemsCount + 10});
}

handleScroll(scrollData){
console.log(scrollData);
}

render() {
var itemElements = [];

Expand All @@ -31,6 +35,7 @@ class App extends React.Component{
verticalContainerStyle={scrollBarStyles}
horizontalScrollbarStyle={scrollBarStyles}
horizontalContainerStyle={scrollBarStyles}
onScroll={this.handleScroll}
>

{itemElements}
Expand Down
10 changes: 10 additions & 0 deletions src/js/scrollArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ export default class ScrollArea extends React.Component{
if(this.canScrollX(newState)){
newState.leftPosition = this.computeLeftPosition(deltaX, newState);
}

if(this.props.onScroll){
this.props.onScroll(newState);
}

this.setState(newState);
}

Expand Down Expand Up @@ -182,6 +187,10 @@ export default class ScrollArea extends React.Component{
e.preventDefault();
}

if(this.props.onScroll){
this.props.onScroll(newState);
}

this.setState(newState);
}

Expand Down Expand Up @@ -309,6 +318,7 @@ ScrollArea.propTypes = {
horizontal: React.PropTypes.bool,
horizontalContainerStyle: React.PropTypes.object,
horizontalScrollbarStyle: React.PropTypes.object,
onScroll: React.PropTypes.func,
contentWindow: React.PropTypes.any,
ownerDocument: React.PropTypes.any
};
Expand Down

0 comments on commit f356c16

Please sign in to comment.