Skip to content

Commit

Permalink
fix(module:slider): fix slider min & max (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthinkxie committed Dec 11, 2017
1 parent 48e40f4 commit 6eda3a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/badge/nz-badge.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { toBoolean } from '../util/convert';
class="ant-scroll-number-only"
[style.transform]="'translateY('+((-countArray[i]*100))+'%)'">
<ng-template [ngIf]="(!nzDot)&&(countArray[i]!=null)">
<p *ngFor="let p of countSingleArray" [class.current]="p==countArray[i]">{{p}}</p>
<p *ngFor="let p of countSingleArray" [class.current]="p==countArray[i]">{{ p }}</p>
</ng-template>
</span></ng-template>
<ng-template [ngIf]="nzCount>nzOverflowCount">{{ nzOverflowCount }}+</ng-template>
Expand Down
4 changes: 2 additions & 2 deletions src/components/slider/nz-slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ export class NzSliderComponent implements ControlValueAccessor, OnInit, OnChange
// clone & sort current value and convert them to offsets, then return the new one
getValueToOffset(value?: SliderValue): SliderValue {
let normalizedValue = value;
if (typeof value === 'undefined') {
if (typeof normalizedValue === 'undefined') {
normalizedValue = this.getValue(true);
}
// TODO: using type guard, remove type cast
return this.nzRange ?
(normalizedValue as number[]).map(val => this.valueToOffset(val)) :
this.valueToOffset(value as number);
this.valueToOffset(normalizedValue as number);
}

writeValue(val: SliderValue): void { // NOTE: writeValue will be called twice when initialized (may BUG? see: https://github.com/angular/angular/issues/14988), here we just ignore the first inited(the first the onValueChange will not registered)
Expand Down
2 changes: 1 addition & 1 deletion src/components/slider/nz-slider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class NzSliderService {
let res = +num;
if (isNaN(res)) { return min; }
if (num < min) { res = min; } else if (num > max) { res = max; }
return num;
return res;
}

/**
Expand Down

0 comments on commit 6eda3a7

Please sign in to comment.