Feat:expandBtnNumHandler选项新增节点实例的回调参数
This commit is contained in:
parent
c8d5a34640
commit
8f8c6c9d95
@ -67,9 +67,7 @@ export const defaultOpt = {
|
|||||||
close: ''
|
close: ''
|
||||||
},
|
},
|
||||||
// 处理收起节点数量
|
// 处理收起节点数量
|
||||||
expandBtnNumHandler: num => {
|
expandBtnNumHandler: null,
|
||||||
return num
|
|
||||||
},
|
|
||||||
// 是否显示带数量的收起按钮
|
// 是否显示带数量的收起按钮
|
||||||
isShowExpandNum: true,
|
isShowExpandNum: true,
|
||||||
// 是否只有当鼠标在画布内才响应快捷键事件
|
// 是否只有当鼠标在画布内才响应快捷键事件
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import btnsSvg from '../../../svg/btns'
|
import btnsSvg from '../../../svg/btns'
|
||||||
import { SVG, Circle, G, Text } from '@svgdotjs/svg.js'
|
import { SVG, Circle, G, Text } from '@svgdotjs/svg.js'
|
||||||
|
import { isUndef } from '../../../utils'
|
||||||
|
|
||||||
// 创建展开收起按钮的内容节点
|
// 创建展开收起按钮的内容节点
|
||||||
function createExpandNodeContent() {
|
function createExpandNodeContent() {
|
||||||
@ -78,7 +79,12 @@ function updateExpandBtnNode() {
|
|||||||
})
|
})
|
||||||
// 计算子节点数量
|
// 计算子节点数量
|
||||||
let count = this.sumNode(this.nodeData.children)
|
let count = this.sumNode(this.nodeData.children)
|
||||||
count = expandBtnNumHandler(count)
|
if (typeof expandBtnNumHandler === 'function') {
|
||||||
|
const res = expandBtnNumHandler(count, this)
|
||||||
|
if (!isUndef(res)) {
|
||||||
|
count = res
|
||||||
|
}
|
||||||
|
}
|
||||||
node.text(String(count))
|
node.text(String(count))
|
||||||
} else {
|
} else {
|
||||||
this._fillExpandNode.stroke('none')
|
this._fillExpandNode.stroke('none')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user