From d51f921317ea09cf482ce1808978f225e461c549 Mon Sep 17 00:00:00 2001 From: Claire <1119518763@qq.com> Date: Wed, 17 May 2023 14:48:31 +0800 Subject: [PATCH] =?UTF-8?q?JSY-29426=20fix:=E7=BB=91=E5=AE=9A=E7=A9=BA?= =?UTF-8?q?=E5=80=BC=E6=97=B6=E4=B8=8E=E5=88=B7=E6=96=B0=E5=90=8E=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/intervalslider/intervalslider.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js index 59b1e1676..6c70c33a3 100644 --- a/src/widget/intervalslider/intervalslider.js +++ b/src/widget/intervalslider/intervalslider.js @@ -103,7 +103,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { var oldValueTwo = self.valueTwo; var v = BI.parseFloat(this.getValue()); self.valueTwo = v; - var percent = self._getPercentByValue(v); + var percent = self._getPercentByValue(v, true); var significantPercent = BI.parseFloat(percent.toFixed(1)); self._setSliderTwoPosition(significantPercent); self._setBlueTrack(); @@ -381,7 +381,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { _setBlueTrack: function () { var percentOne = this._getPercentByValue(this.labelOne.getValue()); - var percentTwo = this._getPercentByValue(this.labelTwo.getValue()); + var percentTwo = this._getPercentByValue(this.labelTwo.getValue(), true); if (percentOne <= percentTwo) { this._setBlueTrackLeft(percentOne); this._setBlueTrackWidth(percentTwo - percentOne); @@ -435,7 +435,11 @@ BI.IntervalSlider = BI.inherit(BI.Single, { }, - _getPercentByValue: function (v) { + _getPercentByValue: function (v, isLast) { + if (this.max === this.min) { + return isLast ? 100 : 0; + } + return (v - this.min) * 100 / (this.max - this.min); }, @@ -545,7 +549,7 @@ BI.IntervalSlider = BI.inherit(BI.Single, { if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) { this.labelOne.setValue(o.digit === false ? this.valueOne : BI.parseFloat(this.valueOne).toFixed(o.digit)); this.labelTwo.setValue(o.digit === false ? this.valueTwo : BI.parseFloat(this.valueTwo).toFixed(o.digit)); - this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo)); + this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo, true)); } else { this.labelOne.setValue(this.min); this.labelTwo.setValue(this.max);