From ba4ff58af6ccf67e255bf43ef905677dc64596a3 Mon Sep 17 00:00:00 2001 From: ascodelife <394922886@qq.com> Date: Mon, 23 Aug 2021 18:47:18 +0800 Subject: [PATCH] feat(Progress): add transition effect --- src/progress/Progress.tsx | 14 ++++++-------- src/progress/demo/index.vue | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/progress/Progress.tsx b/src/progress/Progress.tsx index 02cbacaab..069799815 100644 --- a/src/progress/Progress.tsx +++ b/src/progress/Progress.tsx @@ -3,6 +3,8 @@ import { truthProp, createNamespace, addUnit } from '../utils'; const [name, bem] = createNamespace('progress'); +const transition = 'all 0.3s cubic-bezier(0.46, 0.03, 0.52, 0.96)'; + const props = { color: String, inactive: Boolean, @@ -31,13 +33,6 @@ export default defineComponent({ ); const scaleX = computed(() => +props.percentage! / 100); - const translateX = computed(() => { - let offset = 0; - if (+props.percentage! !== 0) { - offset = (100 - +props.percentage!) / 2 / (+props.percentage! / 100); - } - return `${offset}%`; - }); const renderPivot = () => { const { textColor, pivotText, pivotColor, percentage } = props; @@ -50,6 +45,7 @@ export default defineComponent({ left: `${+percentage!}%`, transform: `translate(-${+percentage!}%,-50%)`, background: pivotColor || background.value, + transition, }; return ( @@ -69,7 +65,9 @@ export default defineComponent({ const portionStyle = { background: background.value, width: '100%', - transform: `scaleX(${scaleX.value}) translateX(-${translateX.value})`, + transform: `scaleX(${scaleX.value})`, + 'transform-origin': 0, + transition, }; return ( diff --git a/src/progress/demo/index.vue b/src/progress/demo/index.vue index e8bb23281..ca784c166 100644 --- a/src/progress/demo/index.vue +++ b/src/progress/demo/index.vue @@ -1,20 +1,47 @@ @@ -40,6 +67,14 @@ const t = useTranslate(i18n); color="linear-gradient(to right, #be99ff, #7232dd)" /> + + + + + {{ t('decrease') }} + {{ t('increase') }} + +