mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(range): fixes when step size is bigger than range
fixes #8830 fixes #8802
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user