Feat:expandBtnNumHandler选项新增节点实例的回调参数

This commit is contained in:
街角小林 2024-09-05 18:21:38 +08:00
parent c8d5a34640
commit 8f8c6c9d95
2 changed files with 8 additions and 4 deletions

View File

@ -67,9 +67,7 @@ export const defaultOpt = {
close: ''
},
// 处理收起节点数量
expandBtnNumHandler: num => {
return num
},
expandBtnNumHandler: null,
// 是否显示带数量的收起按钮
isShowExpandNum: true,
// 是否只有当鼠标在画布内才响应快捷键事件

View File

@ -1,5 +1,6 @@
import btnsSvg from '../../../svg/btns'
import { SVG, Circle, G, Text } from '@svgdotjs/svg.js'
import { isUndef } from '../../../utils'
// 创建展开收起按钮的内容节点
function createExpandNodeContent() {
@ -78,7 +79,12 @@ function updateExpandBtnNode() {
})
// 计算子节点数量
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))
} else {
this._fillExpandNode.stroke('none')