Skip to content

Commit 1ba16af

Browse files
jxhhdxkagol
authored andcommitted
chore(statistic): 修复eslint问题
1 parent cbaf6c5 commit 1ba16af

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

packages/devui-vue/devui/statistic/src/statistic.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineComponent, computed, ref, onMounted, watch } from 'vue';
22
import { statisticProps, StatisticProps } from './statistic-types';
33
import { analysisValueType } from './utils/separator';
44
import { Tween } from './utils/animation';
5+
import type { toType } from './utils/animation';
56
import './statistic.scss';
67

78
export default defineComponent({
@@ -10,7 +11,7 @@ export default defineComponent({
1011
props: statisticProps,
1112
setup(props: StatisticProps, ctx) {
1213
const innerValue = ref(props.valueFrom ?? props.value);
13-
const tween = ref(null);
14+
const tween = ref<Tween | null>(null);
1415

1516
const animation = (
1617
from: number = props.valueFrom ?? 0,
@@ -27,7 +28,7 @@ export default defineComponent({
2728
delay: 0,
2829
duration: props.animationDuration,
2930
easing: 'easeOutCubic',
30-
onUpdate: (keys: any) => {
31+
onUpdate: (keys: toType) => {
3132
innerValue.value = keys.value;
3233
},
3334
onFinish: () => {

packages/devui-vue/devui/statistic/src/utils/animation.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import * as easing from './easing';
2-
3-
export type easingType = 'easeOutCubic' | 'linear' | 'easeOutExpo' | 'easeInOutExpo';
4-
export type startFunc = (key: number) => number;
5-
export type updateFunc = (key: any) => any;
6-
export type finishFunc = (key: any) => any;
1+
import easing from './easing';
72
export interface fromType {
83
value: number;
94
}
105
export interface toType {
116
value: number;
127
}
8+
9+
export type easingType = 'easeOutCubic' | 'linear' | 'easeOutExpo' | 'easeInOutExpo';
10+
export type formAndToAttributesType = 'value' | unknown;
11+
export type startFunc = (key: number) => number;
12+
export type updateFunc = (key: toType) => void;
13+
export type finishFunc = (key: toType) => void;
14+
1315
export interface AnimationOptions {
1416
from: fromType;
1517
to: toType;
@@ -36,9 +38,9 @@ export class Tween {
3638
timer?: null | number;
3739
time?: number;
3840
elapsed?: number;
39-
keys?: any;
41+
keys?: toType;
4042
constructor(options: AnimationOptions) {
41-
const { from, to, duration, delay, easing, onStart, onUpdate, onFinish } = options;
43+
const { from, to, duration, delay, easing: easingValue, onStart, onUpdate, onFinish } = options;
4244
for (const key in from) {
4345
if (to[key] === undefined) {
4446
to[key] = from[key];
@@ -55,7 +57,7 @@ export class Tween {
5557
this.to = to;
5658
this.duration = duration;
5759
this.delay = delay;
58-
this.easing = easing;
60+
this.easing = easingValue;
5961
this.onStart = onStart;
6062
this.onUpdate = onUpdate;
6163
this.onFinish = onFinish;

packages/devui-vue/devui/statistic/src/utils/easing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ export const easeInExpo = function (x: number): number {
2525
export const easeInOutCirc = function (x: number): number {
2626
return x < 0.5 ? (1 - sqrt(1 - pow(2 * x, 2))) / 2 : (sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2;
2727
};
28+
29+
export default { easeOutCubic, linear, easeOutExpo, easeInOutExpo, easeInExpo, easeInOutCirc };

0 commit comments

Comments
 (0)