fix(Progress): width overflow (#13519)
This commit is contained in:
@@ -37,15 +37,18 @@ export default defineComponent({
|
|||||||
props.inactive ? undefined : props.color,
|
props.inactive ? undefined : props.color,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const format = (rate: Numeric) => Math.min(Math.max(+rate, 0), 100);
|
||||||
|
|
||||||
const renderPivot = () => {
|
const renderPivot = () => {
|
||||||
const { textColor, pivotText, pivotColor, percentage } = props;
|
const { textColor, pivotText, pivotColor, percentage } = props;
|
||||||
|
const safePercentage = format(percentage);
|
||||||
const text = pivotText ?? `${percentage}%`;
|
const text = pivotText ?? `${percentage}%`;
|
||||||
|
|
||||||
if (props.showPivot && text) {
|
if (props.showPivot && text) {
|
||||||
const style = {
|
const style = {
|
||||||
color: textColor,
|
color: textColor,
|
||||||
left: `${+percentage}%`,
|
left: `${safePercentage}%`,
|
||||||
transform: `translate(-${+percentage}%,-50%)`,
|
transform: `translate(-${safePercentage}%,-50%)`,
|
||||||
background: pivotColor || background.value,
|
background: pivotColor || background.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,12 +65,13 @@ export default defineComponent({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { trackColor, percentage, strokeWidth } = props;
|
const { trackColor, percentage, strokeWidth } = props;
|
||||||
|
const safePercentage = format(percentage);
|
||||||
const rootStyle = {
|
const rootStyle = {
|
||||||
background: trackColor,
|
background: trackColor,
|
||||||
height: addUnit(strokeWidth),
|
height: addUnit(strokeWidth),
|
||||||
};
|
};
|
||||||
const portionStyle = {
|
const portionStyle = {
|
||||||
width: `${percentage}%`,
|
width: `${safePercentage}%`,
|
||||||
background: background.value,
|
background: background.value,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ const t = useTranslate({
|
|||||||
|
|
||||||
const percentage = ref(50);
|
const percentage = ref(50);
|
||||||
|
|
||||||
const format = (rate: number) => Math.min(Math.max(rate, 0), 100);
|
|
||||||
|
|
||||||
const add = () => {
|
const add = () => {
|
||||||
percentage.value = format(percentage.value + 20);
|
percentage.value = percentage.value + 20;
|
||||||
};
|
};
|
||||||
|
|
||||||
const reduce = () => {
|
const reduce = () => {
|
||||||
percentage.value = format(percentage.value - 20);
|
percentage.value = percentage.value - 20;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user