From c99d31949bec0139dc3e01d91149d4c8625c3bce Mon Sep 17 00:00:00 2001 From: zsmj Date: Tue, 7 Feb 2023 19:02:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=20fix:=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=AE=8C=E4=B9=8B=E5=90=8E=E5=86=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8CsetMinMax=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/singleslider/singleslider.js | 174 +++++++++++++----------- 1 file changed, 95 insertions(+), 79 deletions(-) diff --git a/src/widget/singleslider/singleslider.js b/src/widget/singleslider/singleslider.js index 8cf77b180..4eaf0cc0c 100644 --- a/src/widget/singleslider/singleslider.js +++ b/src/widget/singleslider/singleslider.js @@ -58,16 +58,18 @@ BI.SingleSlider = BI.inherit(BI.Single, { type: "bi.vertical_adapt", cls: "slider-wrapper", columnSize: ["fill"], - items: [{ - type: "bi.absolute", - items: [ - { - el: this.slider, - top: 8, - } - ], - height: c.SLIDER_HEIGHT - }], + items: [ + { + type: "bi.absolute", + items: [ + { + el: this.slider, + top: 8, + } + ], + height: c.SLIDER_HEIGHT + } + ], hgap: c.SLIDER_WIDTH_HALF, height: c.SLIDER_HEIGHT }); @@ -124,41 +126,49 @@ BI.SingleSlider = BI.inherit(BI.Single, { this._setVisible(false); return { type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.track, - width: "100%", - height: c.TRACK_HEIGHT - }] - }], - hgap: c.TRACK_GAP_HALF, - height: c.TRACK_HEIGHT - }, - top: 23, - left: 0, - width: "100%" - }, { - el: sliderVertical, - top: 20, - left: 0, - width: "100%" - }, { - el: { - type: "bi.vertical", - items: [{ - type: "bi.horizontal_auto", - items: [this.label] - }], - // height: c.EDITOR_HEIGHT - }, - top: 0, - left: 0, - width: "100%" - }] + items: [ + { + el: { + type: "bi.vertical", + items: [ + { + type: "bi.absolute", + items: [ + { + el: this.track, + width: "100%", + height: c.TRACK_HEIGHT + } + ] + } + ], + hgap: c.TRACK_GAP_HALF, + height: c.TRACK_HEIGHT + }, + top: 23, + left: 0, + width: "100%" + }, { + el: sliderVertical, + top: 20, + left: 0, + width: "100%" + }, { + el: { + type: "bi.vertical", + items: [ + { + type: "bi.horizontal_auto", + items: [this.label] + } + ], + // height: c.EDITOR_HEIGHT + }, + top: 0, + left: 0, + width: "100%" + } + ] }; }, @@ -198,7 +208,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { self.fireEvent(BI.SingleSlider.EVENT_CHANGE); }, window); widget.element.on("mousedown", function (event) { - if(!widget.isEnabled()) { + if (!widget.isEnabled()) { return; } defaultSize = this.offsetLeft; @@ -206,7 +216,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { mouseMoveTracker.captureMouseMoves(event); }); - function optimizeSize (s) { + function optimizeSize(s) { return BI.clamp(s, 0, self._getGrayTrackLength()); } }, @@ -214,30 +224,36 @@ BI.SingleSlider = BI.inherit(BI.Single, { _createTrackWrapper: function () { return BI.createWidget({ type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.grayTrack, - top: 0, - left: 0, - width: "100%" - }, { - el: this.blueTrack, - top: 0, - left: 0, - width: "0%" - }] - }], - hgap: 8, - height: 8 - }, - top: 8, - left: 0, - width: "100%" - }] + items: [ + { + el: { + type: "bi.vertical", + items: [ + { + type: "bi.absolute", + items: [ + { + el: this.grayTrack, + top: 0, + left: 0, + width: "100%" + }, { + el: this.blueTrack, + top: 0, + left: 0, + width: "0%" + } + ] + } + ], + hgap: 8, + height: 8 + }, + top: 8, + left: 0, + width: "100%" + } + ] }); }, @@ -245,9 +261,9 @@ BI.SingleSlider = BI.inherit(BI.Single, { var o = this.options; var valid = false; if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { - if(o.digit === false) { + if (o.digit === false) { valid = true; - }else{ + } else { var dotText = (v + "").split(".")[1] || ""; valid = (dotText.length === o.digit); } @@ -256,7 +272,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { }, _setBlueTrack: function (percent) { - this.blueTrack.element.css({width: percent + "%"}); + this.blueTrack.element.css({ width: percent + "%" }); }, _setLabelPosition: function (percent) { @@ -264,7 +280,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { }, _setSliderPosition: function (percent) { - this.slider.element.css({left: percent + "%"}); + this.slider.element.css({ left: percent + "%" }); }, _setAllPosition: function (percent) { @@ -314,7 +330,7 @@ BI.SingleSlider = BI.inherit(BI.Single, { _setEnable: function (b) { BI.SingleSlider.superclass._setEnable.apply(this, [b]); - if(b) { + if (b) { this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); } else { this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); @@ -322,9 +338,9 @@ BI.SingleSlider = BI.inherit(BI.Single, { }, setMinAndMax: function (v) { - var minNumber = BI.parseFloat(v.min); - var maxNumber = BI.parseFloat(v.max); - if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { + var minNumber = this.options.min = BI.parseFloat(v.min); + var maxNumber = this.options.max = BI.parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber)) { this.min = minNumber; this.max = maxNumber; }