fix(range): fixes when step size is bigger than range

fixes #8830
fixes #8802
This commit is contained in:
Manu Mtz.-Almeida
2016-10-21 17:21:23 +02:00
parent 90f9b5c42f
commit 9895b86015
6 changed files with 95 additions and 7 deletions

View File

@ -602,16 +602,18 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O
* @private
*/
ratioToValue(ratio: number) {
ratio = Math.round(((this._max - this._min) * ratio) + this._min);
return Math.round(ratio / this._step) * this._step;
ratio = Math.round(((this._max - this._min) * ratio));
ratio = Math.round(ratio / this._step) * this._step + this._min;
return clamp(this._min, ratio, this._max);
}
/**
* @private
*/
valueToRatio(value: number) {
value = Math.round(clamp(this._min, value, this._max) / this._step) * this._step;
return (value - this._min) / (this._max - this._min);
value = Math.round((value - this._min) / this._step) * this._step;
value = value / (this._max - this._min);
return clamp(0, value, 1);
}
/**