From d4c9b17b0f6b6053e8448a601555d1cdadce8f53 Mon Sep 17 00:00:00 2001 From: miomio-xiao Date: Mon, 2 Apr 2018 16:47:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20Slider=E7=BB=84=E4=BB=B6=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1click=E7=9A=84=E6=97=B6=E5=80=99=E4=B8=8D?= =?UTF-8?q?=E8=A7=A6=E5=8F=91on-change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/slider/slider.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue index ec91eebc..c911f52e 100644 --- a/src/components/slider/slider.vue +++ b/src/components/slider/slider.vue @@ -326,11 +326,12 @@ const index = type === 'min' ? 0 : 1; if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; else newPos = this.checkLimits([this.minPosition, newPos])[1]; - + const modulus = this.handleDecimal(newPos,this.step); - const value = this.currentValue; + const value = [...this.currentValue]; value[index] = newPos - modulus; - this.currentValue = [...value]; + this.currentValue = value; + if (!this.dragging) { if (this.currentValue[index] !== this.oldValue[index]) { this.emitChange(); From 42ab875dd09b2b95d57034179ea7da38cd06b6c3 Mon Sep 17 00:00:00 2001 From: miomio-xiao Date: Wed, 4 Apr 2018 09:54:30 +0800 Subject: [PATCH 2/2] fix Slider not emit on-change event when click bar at first time --- 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 c911f52e..9085e747 100644 --- a/src/components/slider/slider.vue +++ b/src/components/slider/slider.vue @@ -151,7 +151,7 @@ startX: 0, currentX: 0, startPos: 0, - oldValue: val, + oldValue: [...val], valueIndex: { min: 0, max: 1, @@ -328,9 +328,9 @@ else newPos = this.checkLimits([this.minPosition, newPos])[1]; const modulus = this.handleDecimal(newPos,this.step); - const value = [...this.currentValue]; + const value = this.currentValue; value[index] = newPos - modulus; - this.currentValue = value; + this.currentValue = [...value]; if (!this.dragging) { if (this.currentValue[index] !== this.oldValue[index]) {