Skip to content

Commit 1a12687

Browse files
authored
fix: vben count to animator event name fixed (#5573)
1 parent a221d2b commit 1a12687

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

docs/src/components/common-ui/vben-count-to-animator.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ outline: deep
4242
| transition | 动画效果 | `string` | `linear` |
4343
| decimals | 保留小数点位数 | `number` | `0` |
4444

45-
### Methods
45+
### Events
46+
47+
| 事件名 | 描述 | 类型 |
48+
| -------------- | -------------- | -------------- |
49+
| started | 动画已开始 | `()=>void` |
50+
| finished | 动画已结束 | `()=>void` |
51+
| ~~onStarted~~ | ~~动画已开始~~ | ~~`()=>void`~~ |
52+
| ~~onFinished~~ | ~~动画已结束~~ | ~~`()=>void`~~ |
4653

47-
以下事件,只有在 `useVbenModal({onCancel:()=>{}})` 中传入才会生效。
54+
### Methods
4855

49-
| 事件名 | 描述 | 类型 |
56+
| 方法名 | 描述 | 类型 |
5057
| ------ | ------------ | ---------- |
5158
| start | 开始执行动画 | `()=>void` |
5259
| reset | 重置 | `()=>void` |

packages/@core/ui-kit/shadcn-ui/src/components/count-to-animator/count-to-animator.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,18 @@ const props = withDefaults(defineProps<Props>(), {
3737
useEasing: true,
3838
});
3939
40-
const emit = defineEmits(['onStarted', 'onFinished']);
40+
const emit = defineEmits<{
41+
finished: [];
42+
/**
43+
* @deprecated 请使用{@link finished}事件
44+
*/
45+
onFinished: [];
46+
/**
47+
* @deprecated 请使用{@link started}事件
48+
*/
49+
onStarted: [];
50+
started: [];
51+
}>();
4152
4253
const source = ref(props.startVal);
4354
const disabled = ref(false);
@@ -73,8 +84,14 @@ function run() {
7384
outputValue = useTransition(source, {
7485
disabled,
7586
duration: props.duration,
76-
onFinished: () => emit('onFinished'),
77-
onStarted: () => emit('onStarted'),
87+
onFinished: () => {
88+
emit('finished');
89+
emit('onFinished');
90+
},
91+
onStarted: () => {
92+
emit('started');
93+
emit('onStarted');
94+
},
7895
...(props.useEasing
7996
? { transition: TransitionPresets[props.transition] }
8097
: {}),

0 commit comments

Comments
 (0)