Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
- added:
    - the enableDragNodeOut property
    - the enableDropExternalElement property
    - the useDefaultIsDroppable property
    - the useDefaultDrop property
    - the dragAndDrop.status property
    - the treeId property
    - the input slot
- fixed:
    - the cursor and the ghost image blinked when the user dragged a node over the edge of another node.
    - the input box's width didn't fit its content well.
    - the input box's content wasn't selected when a node's title was switched to edit mode.
    - the contextmenu wasn't fully displayed if parts of it was outside the container with overflow:hidden.
- security:
    - upgraded some dependencies.
  • Loading branch information
yinquan committed Dec 6, 2020
1 parent 6291ffb commit ba0cbef
Show file tree
Hide file tree
Showing 10 changed files with 5,044 additions and 4,293 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
3.0.0
- added:
- the enableDragNodeOut property
- the enableDropExternalElement property
- the useDefaultIsDroppable property
- the useDefaultDrop property
- the dragAndDrop.status property
- the treeId property
- the input slot
- fixed:
- the cursor and the ghost image blinked when the user dragged a node over the edge of another node.
- the input box's width didn't fit its content well.
- the input box's content wasn't selected when a node's title was switched to edit mode.
- the contextmenu wasn't fully displayed if parts of it was outside the container with overflow:hidden.
- security:
- upgraded some dependencies.

2.14.0
- added:
- the autoHideContextMenu property
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
3.0.0
- 添加:
- 属性 enableDragNodeOut
- 属性 enableDropExternalElement
- 属性 useDefaultIsDroppable
- 属性 useDefaultDrop
- 属性 treeId
- 属性 dragAndDrop.status
- 插槽 input slot
- 修正:
- 当用户拖动一个结点跨过一个结点的边缘时,鼠标及缩略图会闪烁。
- 编辑一个结点的标题时,输入框的宽度不能很好地适应内容的长度。
- 一个结点进入编辑模式时,内容不是选中状态。
- 当父容器有overflow:hidden属性时,右键菜单可能会被遮挡。
- 安全性:
- 升级一些依赖包.

2.14.0
- 添加:
- 属性 autoHideContextMenu
Expand Down
19 changes: 19 additions & 0 deletions example/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import DragAndDropBasicExample from '../views/DragAndDropBasicExample.vue'
import DragAndDropAdvancedExample from '../views/DragAndDropAdvancedExample.vue'
import DragAndDropDisableExample from '../views/DragAndDropDisableExample.vue'
import DragAndDropCustomAppearanceExample from '../views/DragAndDropCustomAppearanceExample.vue'
import DragAndDropDragANodeOutExample from '../views/DragAndDropDragANodeOutExample.vue'
import DragAndDropDropAnExternalElementExample from '../views/DragAndDropDropAnExternalElementExample.vue'
import DragAndDropMultipleTreesExample from '../views/DragAndDropMultipleTreesExample.vue'

import CheckboxWithLinkageExample from '../views/CheckboxWithLinkageExample.vue'
import CheckboxWithoutLinkageExample from '../views/CheckboxWithoutLinkageExample.vue'
Expand Down Expand Up @@ -159,6 +162,22 @@ const routes = [
name: 'drag-and-drop-custom-appearance-example',
component: DragAndDropCustomAppearanceExample
},
{
path: '/:lang/example/drag-and-drop/drag-a-node-out',
name: 'drag-and-drop-drag-a-node-out-example',
component: DragAndDropDragANodeOutExample
},
{
path: '/:lang/example/drag-and-drop/drop-an-external-element',
name: 'drag-and-drop-drop-an-external-element-example',
component: DragAndDropDropAnExternalElementExample
},
{
path: '/:lang/example/drag-and-drop/multiple-trees',
name: 'drag-and-drop-multiple-trees-example',
component: DragAndDropMultipleTreesExample
},


{
path: '/:lang/example/root-node/no-root-node',
Expand Down
120 changes: 120 additions & 0 deletions example/views/DragAndDropDragANodeOutExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<template>
<div class="example-wrapper">
<div class="panel">
<TWTree :tree="tree" ref="tree" cass="tree" :enableDragNodeOut="true"/>
<div
class="container"
@dragover="dragOver"
@drop="dropNode">
{{containerTitle}}
</div>
</div>
</div>
</template>

<script>
import TWTree from '../../src/TWTree.vue'
export default {
name: 'drag-and-drop-drag-a-node-out-example',
components: {
TWTree
},
data() {
return {
containerTitle: 'Drag a node here!',
tree: [
{
id: 1,
title: 'ROOT',
hasChild: true,
children: [
{
id: 2,
title: 'child 1',
},
{
id: 3,
title: 'child 2',
hasChild: true,
children: [
{
id: 4,
title: 'child 2-1'
},
{
id: 5,
title: 'child 2-2'
},
{
id: 6,
title: 'child 2-3'
}
],
},
{
id: 7,
title: 'child 3'
},
{
id: 8,
title: 'child 4'
},
{
id: 9,
title: 'child 5'
},
{
id: 10,
title: 'child 6'
}
]
}
]
}
},
methods: {
dragOver (event) {
event.preventDefault()
},
dropNode (event) {
let obj = JSON.parse(event.dataTransfer.getData('twtree'))
let node = this.$refs.tree.getById(obj.nodeId)
this.containerTitle = node.title
this.$refs.tree.remove(node)
}
}
}
</script>

<style scoped>
.panel {
position: relative;
}
.panel .tree {
width: 50%;
}
.btn {
width: 100px;
margin-right: 20px;
}
.info {
display: block;
width: 100%;
text-align: left;
}
.key {
font-weight: bold;
font-size: 18px;
}
.container {
padding: 0 2em;
line-height: 100px;
width: 150px;
height: 100px;
border: 2px dashed gray;
position: absolute;
left: 60%;
top: 100px;
}
</style>
164 changes: 164 additions & 0 deletions example/views/DragAndDropDropAnExternalElementExample.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<template>
<div class="example-wrapper">
<div class="panel">
<TWTree
:tree="tree"
ref="tree"
class="tree"
:enableDropExternalElement="true"
@drop="drop"/>
<div class="container">
<div
class="draggable-element"
:draggable="true"
@dragstart="dragStartHandler(i)"
:key = i
v-for="(title, i) of draggableElements">
{{title}}
</div>
</div>
</div>
</div>
</template>

<script>
import TWTree from '../../src/TWTree.vue'
export default {
name: 'drag-and-drop-drop-an-external-element-example',
components: {
TWTree
},
data() {
return {
draggableElements: [
'element 1',
'element 2',
'element 3'
],
draggedIdx: null,
tree: [
{
id: 1,
title: 'ROOT',
hasChild: true,
children: [
{
id: 2,
title: 'child 1',
},
{
id: 3,
title: 'child 2',
hasChild: true,
children: [
{
id: 4,
title: 'child 2-1'
},
{
id: 5,
title: 'child 2-2'
},
{
id: 6,
title: 'child 2-3'
}
],
},
{
id: 7,
title: 'child 3'
},
{
id: 8,
title: 'child 4'
},
{
id: 9,
title: 'child 5'
},
{
id: 10,
title: 'child 6'
}
]
}
]
}
},
methods: {
dragStartHandler (idx) {
this.draggedIdx = idx
},
drop (dragAndOver) {
if (dragAndOver.status !== 3) {
return
}
let title = this.draggableElements[this.draggedIdx]
let node = {
id: Date.now(),
title: title,
hasChild: false
}
let overNode = dragAndOver.overNode
switch (dragAndOver.overArea) {
case 'prev':
this.$refs.tree.create(node, overNode.__.parent, overNode.__.pos)
break
case 'self':
this.$refs.tree.create(node, overNode)
break
case 'next':
this.$refs.tree.create(node, overNode.__.parent, overNode.__.pos + 1)
break
}
}
}
}
</script>

<style scoped>
.panel {
position: relative;
}
.panel .tree {
width: 50%;
}
.btn {
width: 100px;
margin-right: 20px;
}
.info {
display: block;
width: 100%;
text-align: left;
}
.key {
font-weight: bold;
font-size: 18px;
}
.container {
padding: 0 2em;
width: 100px;
border: 0;
position: absolute;
left: 60%;
top: 100px;
}
.container .draggable-element {
border: 1px solid gray;
width: auto;
height: 1em;
padding: 0.2em;
margin-bottom: 1em;
font-size: 12px;
}
.container .draggable-element:hover {
background-color: #bae7ff;
}
</style>
Loading

0 comments on commit ba0cbef

Please sign in to comment.