Skip to content

Commit 4c3f334

Browse files
author
yinquan
committed
fix: node.style.titleMaxWidth with a percentage value not working properly.
1 parent 1dfed72 commit 4c3f334

File tree

9 files changed

+24
-10
lines changed

9 files changed

+24
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
1.3.1
2+
fix: node.style.titleMaxWidth with a percentage value not working properly.
3+
add a prop: node.__.titleMaxWidth
4+
15
1.3.0
26
add props: node.style.extraAlwaysVisible, node.style.titleMaxWidth, node.style.titleOverflow, node.__.titleTip
37

48
1.2.2
59
upgrade some dependencies
610

711
1.2.1
8-
fix bug: #2
12+
fix: #2
913

1014
1.2.0
11-
add prop: node.style.extraFloatRight
15+
add a prop: node.style.extraFloatRight
1216

1317
1.1.2
14-
fix bug: dragAndDrop.dragNode and dragAndDrop.overNode are not null when dragend event is triggered.
18+
fix: dragAndDrop.dragNode and dragAndDrop.overNode are not null when dragend event is triggered.
1519

1620
1.1.1
1721
methods:

docs/css/app.60d2f3c4.css renamed to docs/css/app.bf4449b7.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title>twtree</title><link href=js/about.76155aec.js rel=prefetch><link href=css/app.60d2f3c4.css rel=preload as=style><link href=js/app.dfca6e43.js rel=preload as=script><link href=js/chunk-vendors.1b769e65.js rel=preload as=script><link href=css/app.60d2f3c4.css rel=stylesheet></head><body><noscript><strong>We're sorry but twtree doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.1b769e65.js></script><script src=js/app.dfca6e43.js></script></body></html>
1+
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title>twtree</title><link href=js/about.76155aec.js rel=prefetch><link href=css/app.bf4449b7.css rel=preload as=style><link href=js/app.2918e3a6.js rel=preload as=script><link href=js/chunk-vendors.1b769e65.js rel=preload as=script><link href=css/app.bf4449b7.css rel=stylesheet></head><body><noscript><strong>We're sorry but twtree doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.1b769e65.js></script><script src=js/app.2918e3a6.js></script></body></html>

docs/js/app.2918e3a6.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/app.2918e3a6.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/app.dfca6e43.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/js/app.dfca6e43.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twtree",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"description": "A highly customizable tree component for vue, which features checkbox, async loading, drag and drop, context menu and custom appearance.",
55
"main": "lib/twtree.umd.min.js",
66
"keywords": [

src/components/TWTree.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'--checkboxMarginRight': item.style.checkboxMarginRight,
3434
'--extraFloat': item.style.extraFloatRight ? 'right' : 'none',
3535
'--extraDisplay': item.style.extraAlwaysVisible ? 'inline-block' : 'none',
36-
'--titleMaxWidth': item.style.titleMaxWidth,
36+
'--titleMaxWidth': item.__.titleMaxWidth,
3737
'--titleOverflow': item.style.titleOverflow,
3838
'--mousex': item.__.mousex,
3939
'--mousey': item.__.mousey,
@@ -218,6 +218,7 @@ export default {
218218
nodes: JSON.parse(JSON.stringify(this.tree)),
219219
items: this.getItems(),
220220
autoIdCounter: 0,
221+
treeWidth: 0,
221222
spareDefaultAttrs: {
222223
selected: false,
223224
directoryState: 'expanded',
@@ -252,6 +253,7 @@ export default {
252253
height: '2em',
253254
mousex: 0,
254255
mousey: 0,
256+
titleMaxWidth: 'none',
255257
titleTip: ''
256258
}
257259
},
@@ -376,11 +378,19 @@ export default {
376378
this.setAttr(node, '__', 'mousey', this.getAttr(node, '__', 'mousey'))
377379
this.setAttr(node, '__', 'titleTip', this.getAttr(node, '__', 'titleTip'))
378380
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+
this.setAttr(node, '__', 'titleMaxWidth', titleMaxWidth)
379388
}
380389
381390
return items
382391
},
383392
refresh() {
393+
this.treeWidth = this.$refs.tree.offsetWidth
384394
this.items = this.getItems()
385395
this.refreshAllDirectoryCheckboxState()
386396
},

0 commit comments

Comments
 (0)