Skip to content

Add freeze prop to stop dragging events #51

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npm install react-ui-tree --save
<Tree
paddingLeft={20} // left padding for children nodes in pixels
tree={this.state.tree} // tree object
freeze={false} // set it to true to stop dragging events
onChange={this.handleChange} // onChange(tree) tree object changed
renderNode={this.renderNode} // renderNode(node) return react element
/>
Expand Down
3 changes: 2 additions & 1 deletion lib/react-ui-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = React.createClass({
propTypes: {
tree: React.PropTypes.object.isRequired,
paddingLeft: React.PropTypes.number,
freeze: React.PropTypes.bool,
renderNode: React.PropTypes.func.isRequired
},

Expand Down Expand Up @@ -84,7 +85,7 @@ module.exports = React.createClass({
index={tree.getIndex(1)}
key={1}
paddingLeft={this.props.paddingLeft}
onDragStart={this.dragStart}
onDragStart={this.props.freeze ? null : this.dragStart}
onCollapse={this.toggleCollapse}
dragging={dragging && dragging.id}
/>
Expand Down