Skip to content

Commit 01b6726

Browse files
committed
Add canDrag documentation
1 parent c466552 commit 01b6726

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ generateNodeProps | func | | | Ge
5858
getNodeKey | func | defaultGetNodeKey | | Determine the unique key used to identify each node and generate the `path` array passed in callbacks. By default, returns the index in the tree (omitting hidden nodes).<div>`({ node: object, treeIndex: number }): string or number`</div>
5959
onMoveNode | func | | | Called after node move operation. <div>`({ treeData: object[], node: object, treeIndex: number, path: number[] or string[] }): void`</div>
6060
onVisibilityToggle | func | | | Called after children nodes collapsed or expanded. <div>`({ treeData: object[], node: object, expanded: bool }): void`</div>
61+
canDrag | func or bool | `true` | | Return false from callback to prevent node from dragging, by hiding the drag handle. Set prop to `false` to disable dragging on all nodes. <div>`({ node: object, path: number[] or string[], treeIndex: number, lowerSiblingCounts: number[], isSearchMatch: bool, isSearchFocus: bool }): bool`</div>
6162
canDrop | func | | | Return false to prevent node from dropping in the given location. <div>`({ node: object, prevPath: number[] or string[], prevParent: object, nextPath: number[] or string[], nextParent: object}): bool`</div>
6263
reactVirtualizedListProps | object | | | Custom properties to hand to the [react-virtualized list](https://github.com/bvaughn/react-virtualized/blob/master/docs/List.md#prop-types)
6364
rowHeight | number or func | `62` | | Used by react-virtualized. Either a fixed row height (number) or a function that returns the height of a row given its index: `({ index: number }): number`

src/examples/basicExample/app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ class App extends Component {
124124
},
125125
],
126126
},
127+
{
128+
title: 'Disable dragging on a per-node basis with the `canDrag` prop',
129+
subtitle: 'Or set it to false to disable all dragging.',
130+
noDragging: true,
131+
},
127132
{
128133
title: 'You cannot give this children',
129134
subtitle: 'Dropping is prevented via the `canDrop` API using `nextParent`',
@@ -287,6 +292,7 @@ class App extends Component {
287292
maxDepth={maxDepth}
288293
searchQuery={searchString}
289294
searchFocusOffset={searchFocusIndex}
295+
canDrag={({ node }) => !node.noDragging}
290296
canDrop={({ nextParent }) => !nextParent || !nextParent.noChildren}
291297
searchFinishCallback={matches =>
292298
this.setState({

0 commit comments

Comments
 (0)