From af974fc4d0820c15f5c3794328f31872ab39333f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Sofuo=C4=9Flu?= Date: Wed, 12 Oct 2022 08:43:32 +0300 Subject: [PATCH 1/4] Slider range changes completed --- src/components/slider/Slider.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/slider/Slider.vue b/src/components/slider/Slider.vue index 0cc3d59616..79193be458 100755 --- a/src/components/slider/Slider.vue +++ b/src/components/slider/Slider.vue @@ -152,7 +152,7 @@ export default { modelValue = this.modelValue ? [...this.modelValue] : []; if (this.handleIndex == 0) { - let maxValue = this.modelValue ? this.modelValue[1] : this.max; + let maxValue = this.max; if (newValue < this.min) newValue = this.min; else if (newValue >= maxValue) newValue = maxValue; @@ -160,7 +160,7 @@ export default { modelValue[0] = newValue; modelValue[1] = modelValue[1] || this.max; } else { - let minValue = this.modelValue ? this.modelValue[0] : this.min; + let minValue = this.min; if (newValue > this.max) newValue = this.max; else if (newValue <= minValue) newValue = minValue; @@ -334,7 +334,10 @@ export default { }, rangeStyle() { if (this.range) { - if (this.horizontal) return { left: this.rangeStartPosition + '%', width: this.rangeEndPosition - this.rangeStartPosition + '%' }; + const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition; + const rangeSliderPositionLeft = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition; + + if (this.horizontal) return { left: rangeSliderPositionLeft + '%', width: rangeSliderWidth + '%' }; else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' }; } else { if (this.horizontal) return { width: this.handlePosition + '%' }; From ca181012e216b7378a4382099f4167cfb07c682d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Sofuo=C4=9Flu?= Date: Wed, 12 Oct 2022 08:58:51 +0300 Subject: [PATCH 2/4] Slider vertical range changes --- src/components/slider/Slider.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/slider/Slider.vue b/src/components/slider/Slider.vue index 79193be458..c299060261 100755 --- a/src/components/slider/Slider.vue +++ b/src/components/slider/Slider.vue @@ -335,10 +335,10 @@ export default { rangeStyle() { if (this.range) { const rangeSliderWidth = this.rangeEndPosition > this.rangeStartPosition ? this.rangeEndPosition - this.rangeStartPosition : this.rangeStartPosition - this.rangeEndPosition; - const rangeSliderPositionLeft = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition; + const rangeSliderPosition = this.rangeEndPosition > this.rangeStartPosition ? this.rangeStartPosition : this.rangeEndPosition; - if (this.horizontal) return { left: rangeSliderPositionLeft + '%', width: rangeSliderWidth + '%' }; - else return { bottom: this.rangeStartPosition + '%', height: this.rangeEndPosition - this.rangeStartHandlePosition + '%' }; + if (this.horizontal) return { left: rangeSliderPosition + '%', width: rangeSliderWidth + '%' }; + else return { bottom: rangeSliderPosition + '%', height: rangeSliderWidth + '%' }; } else { if (this.horizontal) return { width: this.handlePosition + '%' }; else return { height: this.handlePosition + '%' }; From 8ce3a6602774366ef106a7021a09b86c2559bb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Sofuo=C4=9Flu?= Date: Wed, 12 Oct 2022 10:18:32 +0300 Subject: [PATCH 3/4] Range model value changes --- src/components/slider/Slider.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/slider/Slider.vue b/src/components/slider/Slider.vue index c299060261..4c789fdf1d 100755 --- a/src/components/slider/Slider.vue +++ b/src/components/slider/Slider.vue @@ -157,16 +157,24 @@ export default { if (newValue < this.min) newValue = this.min; else if (newValue >= maxValue) newValue = maxValue; - modelValue[0] = newValue; - modelValue[1] = modelValue[1] || this.max; + if (newValue >= modelValue[1]) { + modelValue[1] = newValue; + } else { + modelValue[0] = newValue; + modelValue[1] = modelValue[1] || this.max; + } } else { let minValue = this.min; if (newValue > this.max) newValue = this.max; else if (newValue <= minValue) newValue = minValue; - modelValue[0] = modelValue[0] || this.min; - modelValue[1] = newValue; + if (newValue <= modelValue[0]) { + modelValue[0] = newValue; + } else { + modelValue[0] = modelValue[0] || this.min; + modelValue[1] = newValue; + } } } else { if (newValue < this.min) newValue = this.min; From 86fef0730342b73a1daf048d27d3da1791ef27dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Sofuo=C4=9Flu?= Date: Wed, 12 Oct 2022 10:53:19 +0300 Subject: [PATCH 4/4] Slider range issue fixed --- src/components/slider/Slider.vue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/slider/Slider.vue b/src/components/slider/Slider.vue index 4c789fdf1d..8b2a5b4efc 100755 --- a/src/components/slider/Slider.vue +++ b/src/components/slider/Slider.vue @@ -152,27 +152,25 @@ export default { modelValue = this.modelValue ? [...this.modelValue] : []; if (this.handleIndex == 0) { - let maxValue = this.max; - if (newValue < this.min) newValue = this.min; - else if (newValue >= maxValue) newValue = maxValue; + else if (newValue >= this.max) newValue = this.max; if (newValue >= modelValue[1]) { modelValue[1] = newValue; + + this.handleIndex = 1; } else { modelValue[0] = newValue; - modelValue[1] = modelValue[1] || this.max; } } else { - let minValue = this.min; - if (newValue > this.max) newValue = this.max; - else if (newValue <= minValue) newValue = minValue; + else if (newValue <= this.min) newValue = this.min; if (newValue <= modelValue[0]) { modelValue[0] = newValue; + + this.handleIndex = 0; } else { - modelValue[0] = modelValue[0] || this.min; modelValue[1] = newValue; } }