From a7317265dce87d19a005f423ea616554ff9f5185 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Mon, 7 Mar 2022 15:29:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(countup):=20=E9=87=8D=E6=9E=84,?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20countup.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/docs/zh-CN/components/countup.md | 73 +++++++++----- package.json | 1 - src/component/countUp/index.vue | 123 +++++++++++++---------- 3 files changed, 119 insertions(+), 78 deletions(-) diff --git a/example/docs/zh-CN/components/countup.md b/example/docs/zh-CN/components/countup.md index 2e8adc86..f5422cd9 100644 --- a/example/docs/zh-CN/components/countup.md +++ b/example/docs/zh-CN/components/countup.md @@ -7,8 +7,8 @@ ::: demo @@ -17,9 +17,9 @@ import { ref } from 'vue' export default { setup() { - const countVal = 2862.9888; + return { - + } } } @@ -38,14 +38,14 @@ export default {
-

+

- + @@ -84,15 +84,18 @@ export default { | 属性 | 描述 | 类型 | 默认值 | 可选值 | | ------------- | ------------------------------------------------------------ | -------------- | ------ | -------------- | +| startVal | 起始值 | number | `0` | — | | endVal | 显示的值 | number | `0` | — | +| decimal | 小数点 | string | `.` | — | | decimalPlaces | 小数位数 | number | `0` | — | -| useGrouping | 使用千位分隔符 | boolean | `true` | `true` `false` | +| useGrouping | 是否使用千位分隔符 | boolean | `true` | `true` `false` | | separator | 分隔符 | string | `,` | — | -| useEasing | 使用动画 | boolean | `true` | `true` `false` | -| duration | 动画持续时间 | number | `2` | — | +| autoplay | 是否自动播放 | boolean | `true` | `true` `false` | +| useEasing | 是否使用动画 | boolean | `true` | `true` `false` | +| easingFn | 动画类型 | Array \| Function \| string | `easeInOutCubic` | — | +| duration | 动画持续时间,单位: ms | number | `2000` | — | | prefix | 前缀 | string | — | — | | suffix | 后缀 | string | — | — | -| option | 选项,用于多实例的总体设置,
props会覆盖option的属性,使用更灵活 | CountUpOptions | — | 参见[CountUpOptions](#opts) | ::: @@ -108,23 +111,45 @@ export default { ::: -::: title Count Up Options 属性 +::: title Count Up 动画类型 ::: -::: table - -| 属性 | 描述 | 类型 | 默认值 | 可选值 | -| ------------- | ------------------------------------------------------------ | -------------- | ------ | -------------- | -| startVal | 开始值 | number | `0` | — | -| decimalPlaces | 小数位数 | number | `0` | — | -| useGrouping | 使用千位分隔符 | boolean | `true` | `true` `false` | -| separator | 分隔符 | string | `,` | — | -| useEasing | 使用动画 | boolean | `true` | `true` `false` | -| duration | 动画持续时间 | number | `2` | — | -| prefix | 前缀 | string | — | — | -| suffix | 后缀 | string | — | — | | - +::: describe 可使用贝塞尔曲线定义动画 ::: +``` +easingFn: [0.75, 0, 0.25, 1] +``` + +::: describe 也可以使用自定义函数 +::: + +``` +const easeOutElastic = (n) => { + return n === 0 + ? 0 + : n === 1 + ? 1 + : (2 ** (-10 * n)) * Math.sin((n * 10 - 0.75) * ((2 * Math.PI) / 3)) + 1 +} + +easingFn: easeOutElastic +``` + +::: describe 通过以下字符串快速设置动画类型 +::: + +``` +easeInSine easeOutSine easeInOutSine +easeInQuad easeOutQuad easeInOutQuad +easeInCubic easeOutCubic easeInOutCubic +easeInQuart easeOutQuart easeInOutQuart +easeInQuint easeOutQuint easeInOutQuint +easeInExpo easeOutExpo easeInOutExpo +easeInCirc easeOutCirc easeInOutCirc +easeInBack easeOutBack easeInOutBack +linear +``` + ::: previousNext countUp ::: \ No newline at end of file diff --git a/package.json b/package.json index 4e5bdb78..d41fc66b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "@layui/layer-vue": "^1.3.5", "@vueuse/core": "^7.6.2", "async-validator": "^4.0.7", - "countup.js": "^2.0.8", "evtd": "^0.2.3", "vue": "^3.2.31", "vue-i18n": "^9.1.9", diff --git a/src/component/countUp/index.vue b/src/component/countUp/index.vue index 4e37574e..1937927b 100644 --- a/src/component/countUp/index.vue +++ b/src/component/countUp/index.vue @@ -1,9 +1,3 @@ - - + +