Skip to content

Commit c4d9397

Browse files
authored
fix(progressbar): improve progressbar animation (#306)
* fix(progressbar): improve progressbar animation * fix(progressbar): minor fixes on progress bar
1 parent 68ee49a commit c4d9397

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lib/progressbar/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ProgressBar extends React.Component {
1818
}
1919

2020
componentDidUpdate(props) {
21-
this.progress.style.width = `${props.progress}%`;
21+
this.progress.style.transform = `scaleX(${((props.progress || 0.01) / 100)})`;
2222
}
2323

2424
render() {
@@ -52,7 +52,7 @@ ProgressBar.propTypes = {
5252
ProgressBar.defaultProps = {
5353
theme: defaultTheme,
5454
type: 'primary',
55-
progress: 0,
55+
progress: 0.01,
5656
showProgressText: false,
5757
};
5858

lib/progressbar/tests/accessibility.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('ProgressBar accessibility tests', () => {
4545
});
4646

4747
it('Should accept a progress prop to update progress effectively.', () => {
48-
expectedValueBefore = 0;
48+
expectedValueBefore = 0.01;
4949
let progress = 0;
5050
actualValue = () => wrappedComponent
5151
.find(ProgressBar)

lib/progressbar/theme.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020

2121
:local(.progress) {
2222
height: 100%;
23-
width: 0%;
23+
width: 100%;
24+
will-change: transform;
25+
transform: scaleX(0);
26+
position: absolute;
27+
left: 0;
28+
transform-origin: left;
29+
transition: transform 0.07s linear;
2430
}
2531

2632
:local(.primary) {

0 commit comments

Comments
 (0)