From 61004008ff162fd40e80a01386768509931fe9cf Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Fri, 3 Mar 2017 23:49:01 +0100 Subject: [PATCH] fix(range): bar width works as expected fixes #10150 --- src/components/range/range.ts | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/range/range.ts b/src/components/range/range.ts index 8e557e7e714..7442f15a034 100644 --- a/src/components/range/range.ts +++ b/src/components/range/range.ts @@ -428,18 +428,14 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O // update which knob is pressed this._pressed = isPressed; - + let valChanged = false; if (this._activeB) { // when the pointer down started it was determined // that knob B was the one they were interacting with this._pressedB = isPressed; this._pressedA = false; this._ratioB = ratio; - - if (val === this._valB) { - // hasn't changed - return false; - } + valChanged = val === this._valB; this._valB = val; } else { @@ -447,13 +443,13 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O this._pressedA = isPressed; this._pressedB = false; this._ratioA = ratio; - - if (val === this._valA) { - // hasn't changed - return false; - } + valChanged = val === this._valA; this._valA = val; } + this._updateBar(); + if (valChanged) { + return false; + } // value has been updated if (this._dual) { @@ -478,8 +474,6 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O this.ionChange.emit(this); }); - this._updateBar(); - return true; } @@ -572,8 +566,7 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O /** @internal */ _valueToRatio(value: number) { - value = Math.round((value - this._min) / this._step) * this._step; - value = value / (this._max - this._min); + value = (value - this._min) / (this._max - this._min); return clamp(0, value, 1); }