You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can drag a node that has the `draggable` property in a node's `treeNodeSpec` set to `true`. Any node with `allowDrop` set to `true` in the `treeNodeSpec` can accept a drop from any TreeView.
- Drag n' Drop ([#6](https://github.com/grapoza/vue-tree/issues/6))
26
+
For future plans, see the project's [Issues](https://github.com/grapoza/vue-tree/issues) page.
30
27
31
28
## Installation
32
29
@@ -201,6 +198,8 @@ The `treeNodeSpec` property contains any data about the node's capabilities and
201
198
| selectable | Boolean | True to allow the node to be selected | `false` | |
202
199
| deletable | Boolean | True to allow the node to be deleted | `false` | |
203
200
| focusable | Boolean | True to make the node the focus when the treeview is focused | See [Aria](#focusable) for details | |
201
+
| draggable | Boolean | True to make this node draggable | `false` | |
202
+
| allowDrop | Boolean | True to allow dropping TreeViewNode data onto this node | `false` | |
204
203
| expanderTitle | String | The text to use as the title for the expander button | `null` | |
205
204
| addChildTitle | String | The text to use as the title for the Add Child button | `null` | |
206
205
| deleteTitle | String | The text to use as the title for the Delete button | `null` | |
@@ -272,26 +271,33 @@ If specified, the `modelDefaults` property of the treeview will be merged with n
272
271
273
272
The display of the treeview can be customized via CSS using the following classes. Class names are organized in a hierarchy, so a containing node's class is the prefix of its child classes.
| `tree-view-node-self-selected` | A selected node |
279
+
| `tree-view-node-self` | The div containing the current node's UI |
280
+
| `tree-view-node-self-expander` | The button used to expand the children |
281
+
| `tree-view-node-self-expanded` | Applied to the expander button when the node is expanded |
282
+
| `tree-view-node-self-expanded-indicator` | The `<i>` element containing the expansion indicator |
283
+
| `tree-view-node-self-spacer` | An empty spacer to replace fixed-width elements, _e.g._ the expander or checkbox |
284
+
| `tree-view-node-self-label` | The label for the checkbox of checkable nodes |
285
+
| `tree-view-node-self-input` | Any type of input field within the tree node |
286
+
| `tree-view-node-self-checkbox` | The checkbox |
287
+
| `tree-view-node-self-radio` | The radio button |
288
+
| `tree-view-node-self-text` | The text for a non-input node |
289
+
| `tree-view-node-self-action` | The action buttons (e.g., add child or delete) |
290
+
| `tree-view-node-self-add-child-icon` | The `<i>` element containing the add child icon |
291
+
| `tree-view-node-self-delete-icon` | The `<i>` element containing the delete icon |
292
+
| `tree-view-node-self-drop-target` | A node has another node dragged over it and can accept drops |
293
+
| `tree-view-node-self-child-drop-target` | A node has another node dragged over its child drop target |
294
+
| `tree-view-node-self-sibling-drop-target` | Either the previous or next sibling node drop target |
295
+
| `tree-view-node-self-sibling-drop-target-hover` | A node has another node dragged over one of the sibling drop targets |
296
+
| `tree-view-node-self-prev-target` | The previous sibling node drop target |
297
+
| `tree-view-node-self-next-target` | The next sibling node drop target |
298
+
| `tree-view-node-children` | The list of child nodes |
299
+
| `tree-view-node-loading` | The placeholder shown when child nodes are loading asynchronously |
300
+
| `tree-view-node-dragging` | The node is dragged as part of a drag and drop operation |
295
301
296
302
## Customizing the TreeView
297
303
@@ -395,6 +401,20 @@ The method may accept one argument, which will be the model of the node that has
395
401
396
402
The load method is called once, and after that the children are part of the model and are not reloaded.
397
403
404
+
## Drag and Drop
405
+
406
+
A user can drag and drop an individual TreeViewNode. A drag only affects the node where the dragging starts, and has nothing to do with any node selection within the tree. To make a node draggable, the node's `treeNodeSpec.draggable` must be `true`. To make a node accept drops, the node's `treeNodeSpec.allowDrop` must be `true`. Both Move and Copy operations are supported. To copy in most browsers hold down the `Ctrl` key while dragging.
407
+
408
+
When dropping a node on another node, there are three areas of the target node where a drop can occur. If dropped at the top of the target node in the shaded area then the node will be inserted before the target. If dropped at the bottom of the target node in the shaded area then the node will be inserted after the target. If dropped directly on the of the target node then the node will be inserted as a child of the target. The drop can occur on a node in the same tree or in a different tree as long as the receiving node allows drops.
409
+
410
+
The drop can also occur anywhere that allows dropping data with the `application/json` or `text/plain` MIME types (_e.g._, a simple text input field or a text editor).
411
+
412
+
When copying a node the newly created node will have its own unique identifier, will not be the currently focusable node even if the source node was the focusable node.
413
+
414
+
When moving a node within the same tree, the actual node is moved within the tree data. If the node is copied within the same tree, any function members of the node data (_e.g._, the addChildCallback) are copied.
415
+
416
+
When a node is moved or copied to a different tree, the node data that passes between trees does not contain any of the functions from the original node data.
417
+
398
418
## Aria
399
419
400
420
ARIA Accessibility recommendations have been implemented at a basic level. This means keyboard navigation follows ARIA recommendations, but the component has not been tested with a screen reader and, since many screen readers exhibit different behaviors for treeview controls anyway, it would be expected to fail articulation checks in many cases. Additionally, some recommended keyboard controls are not implemented (e.g., Expand All Nodes, Type-ahead Focusing). When using the component, there are only a couple of things you need to know.
0 commit comments