Skip to content

Commit

Permalink
feat: added scrollToAlignment property
Browse files Browse the repository at this point in the history
* Expose List scrollToAlignment property

* Added definition for scrollToAlignment prop

* Added scrollToAlignment to TreeContainer
  • Loading branch information
wheelibin authored and diogofcunha committed Mar 4, 2019
1 parent 046f2a6 commit 831ba2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface TreeProps {
nodeMarginLeft?: number;
width?: number;
scrollToId?: number;
scrollToAlignment?: string;
}

export default class Tree extends React.Component<TreeProps> {}
Expand Down
5 changes: 4 additions & 1 deletion src/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Tree extends React.Component {
};

render() {
const {nodes, width, scrollToIndex} = this.props;
const {nodes, width, scrollToIndex, scrollToAlignment} = this.props;

return (
<AutoSizer disableWidth={Boolean(width)}>
Expand All @@ -81,6 +81,7 @@ export default class Tree extends React.Component {
rowRenderer={this.measureRowRenderer(nodes)}
width={width || autoWidth}
scrollToIndex={scrollToIndex}
scrollToAlignment={scrollToAlignment}
/>
)}
</AutoSizer>
Expand All @@ -94,4 +95,6 @@ Tree.propTypes = {
onChange: PropTypes.func.isRequired,
nodeMarginLeft: PropTypes.number,
width: PropTypes.number,
scrollToIndex: PropTypes.number,
scrollToAlignment: PropTypes.string,
};
2 changes: 2 additions & 0 deletions src/TreeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class TreeContainer extends React.Component {
onChange={this.handleChange}
NodeRenderer={this.props.children}
scrollToIndex={rowIndex}
scrollToAlignment={this.props.scrollToAlignment}
/>
);
}
Expand All @@ -67,6 +68,7 @@ TreeContainer.propTypes = {
nodeMarginLeft: PropTypes.number,
width: PropTypes.number,
scrollToId: PropTypes.number,
scrollToAlignment: PropTypes.string,
};

TreeContainer.defaultProps = {
Expand Down

0 comments on commit 831ba2d

Please sign in to comment.