Skip to content

Commit d79d9fb

Browse files
wesleychopkozlowski-opensource
authored andcommittedJun 29, 2016
feat(progresbar): add animation support
- Add support for animation via `.progress-animated` class Closes ng-bootstrap#292
1 parent 75b2a8d commit d79d9fb

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
 

Diff for: ‎src/progressbar/progressbar.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,30 @@ describe('ng-progressbar', () => {
120120
});
121121
})));
122122

123+
it('accepts animated as boolean attr', async(inject([TestComponentBuilder], (tcb) => {
124+
const html = '<ngb-progressbar [value]="value" animated></ngb-progressbar>';
125+
126+
tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
127+
fixture.detectChanges();
128+
129+
expect(getProgressbar(fixture.nativeElement)).toHaveCssClass('progress-animated');
130+
});
131+
})));
132+
133+
it('accepts animated as normal attr', async(inject([TestComponentBuilder], (tcb) => {
134+
const html = '<ngb-progressbar [value]="value" [animated]="animated"></ngb-progressbar>';
135+
136+
tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
137+
fixture.detectChanges();
138+
139+
expect(getProgressbar(fixture.nativeElement)).toHaveCssClass('progress-animated');
140+
141+
fixture.componentInstance.animated = false;
142+
fixture.detectChanges();
143+
expect(getProgressbar(fixture.nativeElement)).not.toHaveCssClass('progress-animated');
144+
});
145+
})));
146+
123147
it('accepts striped as boolean attr', async(inject([TestComponentBuilder], (tcb) => {
124148
const html = '<ngb-progressbar [value]="value" striped></ngb-progressbar>';
125149

@@ -150,6 +174,7 @@ describe('ng-progressbar', () => {
150174
class TestComponent {
151175
value = 10;
152176
max = 50;
177+
animated = true;
153178
striped = true;
154179
type = 'warning';
155180
}

Diff for: ‎src/progressbar/progressbar.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {getValueInRange, toBoolean} from '../util/util';
55
selector: 'ngb-progressbar',
66
changeDetection: ChangeDetectionStrategy.OnPush,
77
template: `
8-
<progress class="progress {{isStriped() && 'progress-striped'}} {{type && 'progress-' + type}}" [value]="getValue()" [max]="max">
8+
<progress class="progress {{isAnimated() && 'progress-animated'}} {{isStriped() && 'progress-striped'}} {{type && 'progress-' + type}}"
9+
[value]="getValue()" [max]="max">
910
<div class="progress">
1011
<span class="progress-bar" [style.width.%]="getPercentValue()"><ng-content></ng-content></span>
1112
</div>
@@ -14,10 +15,13 @@ import {getValueInRange, toBoolean} from '../util/util';
1415
})
1516
export class NgbProgressbar {
1617
@Input() max: number = 100;
18+
@Input() animated: boolean | string;
1719
@Input() striped: boolean | string;
1820
@Input() type: string;
1921
@Input() value: number;
2022

23+
isAnimated(): boolean { return toBoolean(this.animated); }
24+
2125
isStriped(): boolean { return toBoolean(this.striped); }
2226

2327
getValue() { return getValueInRange(this.value, this.max); }

0 commit comments

Comments
 (0)
Please sign in to comment.