Skip to content

Commit

Permalink
feat(linear-progress): add getBuffer
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 359129606
  • Loading branch information
allan-chen authored and copybara-github committed Feb 23, 2021
1 parent 8ecd7c9 commit 9c85d50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mdc-linear-progress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ MDC Linear Progress Foundation exposes the following methods:
| `setProgress(value: number) => void` | Sets the progress bar to this value. Value should be between [0, 1]. |
| `getProgress() => number` | The current progress value in the interval [0,1]. |
| `setBuffer(value: number) => void` | Sets the buffer bar to this value. Value should be between [0, 1]. |
| `getBuffer() => number` | The current buffer value in the interval [0,1]. |
| `open() => void` | Puts the component in the open state. |
| `close() => void` | Puts the component in the closed state. |
| `isClosed() => boolean` | Whether or not the progress indicator is closed. |
Expand Down
4 changes: 4 additions & 0 deletions packages/mdc-linear-progress/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export class MDCLinearProgressFoundation extends
}
}

getBuffer() {
return this.buffer;
}

open() {
this.adapter.removeClass(cssClasses.CLOSED_CLASS);
this.adapter.removeClass(cssClasses.CLOSED_ANIMATION_OFF_CLASS);
Expand Down
2 changes: 2 additions & 0 deletions packages/mdc-linear-progress/test/foundation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ describe('MDCLinearProgressFoundation', () => {
.toHaveBeenCalledWith('transform', 'scaleX(0.5)');
expect(mockAdapter.setAttribute)
.toHaveBeenCalledWith(strings.ARIA_VALUENOW, '0.5');
expect(foundation.getProgress()).toEqual(0.5);
});

it('#setProgress on indeterminate does nothing', () => {
Expand All @@ -286,6 +287,7 @@ describe('MDCLinearProgressFoundation', () => {
foundation.setBuffer(0.5);
expect(mockAdapter.setBufferBarStyle)
.toHaveBeenCalledWith('flex-basis', '50%');
expect(foundation.getBuffer()).toEqual(0.5);
});

it('#setBuffer on indeterminate does nothing', () => {
Expand Down

0 comments on commit 9c85d50

Please sign in to comment.