Skip to content

Commit 29e3d8d

Browse files
committed
feat: setExpand 支持展开动画
1 parent a3b5152 commit 29e3d8d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/components/Tree.vue

+15-3
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ export interface TreeProps {
220220
221221
/** 渲染节点数量,可见节点数大于此值且高度超过(容器可视高度能容纳节点数 + bufferNodeAmount)则不会渲染所有可见节点 */
222222
renderNodeAmount?: number,
223-
223+
224224
/** 根据节点最小高度计算数据总高度 */
225225
nodeMinHeight?: number,
226-
226+
227227
/** 当滚动到视野外的节点个数大于此值时刷新渲染节点 */
228228
bufferNodeAmount?: number,
229229
}
@@ -288,6 +288,7 @@ import { usePublicTreeAPI } from '../hooks/usePublicTreeAPI'
288288
import { FilterFunctionType } from '../store/tree-store'
289289
import { pickReadonly } from '../utils'
290290
import { useExpandAnimation } from '../hooks/useExpandAnimation'
291+
import {ArgumentsType} from "vitest";
291292
292293
const props = withDefaults(defineProps<TreeProps>(), DEFAULT_TREE_PROPS)
293294
@@ -677,6 +678,17 @@ const treeNodePropKeys = [
677678
678679
const treeNodeProps = reactive(pickReadonly(toRefs(props), ...treeNodePropKeys))
679680
681+
const setExpandExpose = (...args: ArgumentsType<typeof setExpand>) => {
682+
if (props.animation) {
683+
const node = getNode(args[0]);
684+
if(node) {
685+
expandAnimation.updateBeforeExpand(node)
686+
}
687+
}
688+
689+
setExpand(...args)
690+
}
691+
680692
defineExpose({
681693
setData,
682694
setChecked,
@@ -685,7 +697,7 @@ defineExpose({
685697
clearChecked,
686698
setSelected,
687699
clearSelected,
688-
setExpand,
700+
setExpand: setExpandExpose,
689701
setExpandKeys,
690702
setExpandAll,
691703
getCheckedNodes,

0 commit comments

Comments
 (0)