|
7 | 7 | :style="{
|
8 | 8 | '--dragImageOffsetX': dragImageOffsetX,
|
9 | 9 | '--dragImageOffsetY': dragImageOffsetY,
|
10 |
| - '--animationDuration': animationDuration |
| 10 | + '--animationDuration': animationDuration, |
| 11 | + '--treeWidth': treeWidth + 'px' |
11 | 12 | }">
|
12 | 13 | <transition-group name="node">
|
13 | 14 | <template v-for="item of items">
|
|
22 | 23 | 'drag-over-self': item.__.dragOverArea === 'self' && item.__.isDroppable
|
23 | 24 | }"
|
24 | 25 | :style="{
|
25 |
| - 'text-indent': item.__.fullIndent, |
| 26 | + '--fullIndent': item.__.fullIndent, |
26 | 27 | '--height': item.style.height,
|
27 | 28 | '--fontSize': item.style.fontSize,
|
28 | 29 | '--hoverBgColor': item.style.hoverBgColor,
|
|
86 | 87 | </svg>
|
87 | 88 | </slot>
|
88 | 89 | </span>
|
89 |
| - <slot name="title" v-bind:node="item"> |
90 |
| - <span |
91 |
| - :class="{title:true, editing:item.__.isEditing}" |
92 |
| - :ref="'title-' + item.id" |
93 |
| - :contenteditable="item.__.isEditing" |
94 |
| - :title="item.__.titleTip" |
95 |
| - @keydown="keydownEvent(item, $event)" |
96 |
| - @keyup="keyupEvent(item, $event)" |
97 |
| - @keypress="keypressEvent(item, $event)" |
98 |
| - @input="inputEvent(item, $event)" |
99 |
| - @focus="focusEvent(item, $event)" |
100 |
| - @blur="blurEvent(item)" |
101 |
| - @mouseenter="mouseenterEvent(item)">{{item.title}}</span> |
102 |
| - </slot> |
| 90 | + <span class="title-wrapper" :ref="'title-' + item.id"> |
| 91 | + <slot name="title" v-bind:node="item"> |
| 92 | + <span |
| 93 | + :class="{title:true, editing:item.__.isEditing}" |
| 94 | + :contenteditable="item.__.isEditing" |
| 95 | + :title="item.__.titleTip" |
| 96 | + @keydown="keydownEvent(item, $event)" |
| 97 | + @keyup="keyupEvent(item, $event)" |
| 98 | + @keypress="keypressEvent(item, $event)" |
| 99 | + @input="inputEvent(item, $event)" |
| 100 | + @focus="focusEvent(item, $event)" |
| 101 | + @blur="blurEvent(item)" |
| 102 | + @mouseenter="mouseenterEvent(item)">{{item.title}}</span> |
| 103 | + </slot> |
| 104 | + </span> |
103 | 105 | </span>
|
104 | 106 | <span class="extra-wrapper">
|
105 | 107 | <slot name="extra" v-bind:node="item">
|
@@ -219,6 +221,7 @@ export default {
|
219 | 221 | items: this.getItems(),
|
220 | 222 | autoIdCounter: 0,
|
221 | 223 | treeWidth: 0,
|
| 224 | + treeWidthInterval: null, |
222 | 225 | spareDefaultAttrs: {
|
223 | 226 | selected: false,
|
224 | 227 | directoryState: 'expanded',
|
@@ -344,6 +347,20 @@ export default {
|
344 | 347 | fullIndent = 'calc(' + indents.join(' + ') + ')'
|
345 | 348 | }
|
346 | 349 |
|
| 350 | + let titleMaxWidth = this.getAttr(node, 'style', 'titleMaxWidth') |
| 351 | + let fullIndentVal = fullIndent.toString() |
| 352 | + if (fullIndentVal.substring(0, 3) === 'calc') { |
| 353 | + fullIndentVal = fullIndentVal.substring(5, fullIndent.length-1) |
| 354 | + } |
| 355 | + if (titleMaxWidth[0] === '-') { |
| 356 | + if (titleMaxWidth[titleMaxWidth.length - 1] === '%') { |
| 357 | + titleMaxWidth = ' - ' + (-1 * parseFloat(titleMaxWidth) / 100.0) + ' * var(--treeWidth)' |
| 358 | + } |
| 359 | + titleMaxWidth = 'calc(var(--treeWidth) - 1em - var(--switcherMarginRight) - 2px - 1em - var(--iconMarginRight) ' + titleMaxWidth + ' - (' + fullIndentVal + '))' |
| 360 | + } else if(titleMaxWidth[titleMaxWidth.length - 1] === '%') { |
| 361 | + titleMaxWidth = 'calc(' + (parseFloat(titleMaxWidth) / 100.0) + ' * var(--treeWidth))' |
| 362 | + } |
| 363 | +
|
347 | 364 | this.setAttr(node, 'directoryState', this.getDirectoryState(node))
|
348 | 365 | this.setAttr(node, 'selected', this.getAttr(node, 'selected'))
|
349 | 366 |
|
@@ -378,12 +395,6 @@ export default {
|
378 | 395 | this.setAttr(node, '__', 'mousey', this.getAttr(node, '__', 'mousey'))
|
379 | 396 | this.setAttr(node, '__', 'titleTip', this.getAttr(node, '__', 'titleTip'))
|
380 | 397 | this.setAttr(node, '__', 'fullIndent', fullIndent)
|
381 |
| -
|
382 |
| - let titleMaxWidth = this.getAttr(node, 'style', 'titleMaxWidth'); |
383 |
| - if (titleMaxWidth[titleMaxWidth.length - 1] === '%') { |
384 |
| - let percent = parseFloat(titleMaxWidth) |
385 |
| - titleMaxWidth = Math.floor(this.treeWidth * percent / 100) + 'px' |
386 |
| - } |
387 | 398 | this.setAttr(node, '__', 'titleMaxWidth', titleMaxWidth)
|
388 | 399 | }
|
389 | 400 |
|
@@ -521,7 +532,7 @@ export default {
|
521 | 532 | getTitleElement(node) {
|
522 | 533 | let refId = 'title-' + node.id
|
523 | 534 | if (this.$refs.hasOwnProperty(refId)) {
|
524 |
| - return this.$refs[refId][0] |
| 535 | + return this.$refs[refId][0].childNodes[0] |
525 | 536 | }
|
526 | 537 |
|
527 | 538 | return null
|
@@ -1191,10 +1202,23 @@ export default {
|
1191 | 1202 | } else if (state === 'collapsed') {
|
1192 | 1203 | this.expand(node)
|
1193 | 1204 | }
|
| 1205 | + }, |
| 1206 | + resizeTree() { |
| 1207 | + this.treeWidth = this.$refs.tree.offsetWidth |
1194 | 1208 | }
|
1195 | 1209 | },
|
1196 | 1210 | mounted() {
|
1197 | 1211 | this.refresh()
|
| 1212 | +
|
| 1213 | + this.treeWidthInterval = setInterval(function(){ |
| 1214 | + let treeWidth = this.$refs.tree.offsetWidth |
| 1215 | + if (this.treeWidth !== treeWidth) { |
| 1216 | + this.treeWidth = treeWidth |
| 1217 | + } |
| 1218 | + }.bind(this), 300) |
| 1219 | + }, |
| 1220 | + beforeDestroy() { |
| 1221 | + clearInterval(this.treeWidthInterval) |
1198 | 1222 | }
|
1199 | 1223 | }
|
1200 | 1224 | </script>
|
@@ -1222,6 +1246,7 @@ export default {
|
1222 | 1246 | font-size: var(--fontSize);
|
1223 | 1247 | margin-top: var(--marginTop);
|
1224 | 1248 | margin-bottom: var(--marginBottom);
|
| 1249 | + text-indent: var(--fullIndent); |
1225 | 1250 | }
|
1226 | 1251 | .node-enter-to, .node-leave {
|
1227 | 1252 | height: var(--height);
|
@@ -1325,35 +1350,39 @@ export default {
|
1325 | 1350 | }
|
1326 | 1351 | .node .drag-arrow-wrapper {
|
1327 | 1352 | height: 0;
|
1328 |
| - width: 100%; |
| 1353 | + width: 0; |
1329 | 1354 | border: 0;
|
| 1355 | + text-indent: 0; |
1330 | 1356 | position: absolute;
|
1331 |
| - left: 0; |
| 1357 | + left: calc(var(--fullIndent) + 1em); |
1332 | 1358 | display: none;
|
1333 |
| - overflow: visible; |
1334 |
| - z-index: 10; |
1335 | 1359 | flex-direction: row;
|
| 1360 | + flex-wrap: nowrap; |
| 1361 | + justify-content: flex-end; |
1336 | 1362 | align-items: center;
|
| 1363 | + overflow: hidden; |
| 1364 | + z-index: 10; |
1337 | 1365 | }
|
1338 | 1366 | .node .drag-arrow-wrapper .arrow {
|
1339 |
| - position: relative; |
1340 |
| - width: 20px; |
1341 |
| - height: 20px; |
1342 |
| - left: -8px; |
1343 |
| - top: -10px; |
| 1367 | + width: 1.7em; |
| 1368 | + height: 2.6em; |
1344 | 1369 | stroke: #5cb85c;
|
1345 | 1370 | fill: #5cb85c;
|
| 1371 | + overflow: visible; |
1346 | 1372 | }
|
1347 | 1373 | .node.drag-over-prev .drag-arrow-wrapper {
|
1348 |
| - display: block; |
| 1374 | + display: flex; |
| 1375 | + overflow: visible; |
1349 | 1376 | top: 0;
|
1350 | 1377 | }
|
1351 | 1378 | .node.drag-over-next .drag-arrow-wrapper {
|
1352 |
| - display: block; |
| 1379 | + display: flex; |
| 1380 | + overflow: visible; |
1353 | 1381 | bottom: 0;
|
1354 | 1382 | }
|
1355 | 1383 | .node.drag-over-self .drag-arrow-wrapper {
|
1356 |
| - display: block; |
| 1384 | + display: flex; |
| 1385 | + overflow: visible; |
1357 | 1386 | top: 50%;
|
1358 | 1387 | }
|
1359 | 1388 | .node.drag-over-self .icon-and-title {
|
|
0 commit comments