Commit 0e6b84f3796ad1239caea3b52895ffbecb1fb510

Authored by Aresn
Committed by GitHub
2 parents 15342275 42ab875d

Merge pull request #3291 from miomio-xiao/2.0

fix Slider not emit on-change event when click bar at first time
Showing 1 changed file with 3 additions and 2 deletions   Show diff stats
src/components/slider/slider.vue
@@ -151,7 +151,7 @@ @@ -151,7 +151,7 @@
151 startX: 0, 151 startX: 0,
152 currentX: 0, 152 currentX: 0,
153 startPos: 0, 153 startPos: 0,
154 - oldValue: val, 154 + oldValue: [...val],
155 valueIndex: { 155 valueIndex: {
156 min: 0, 156 min: 0,
157 max: 1, 157 max: 1,
@@ -326,11 +326,12 @@ @@ -326,11 +326,12 @@
326 const index = type === 'min' ? 0 : 1; 326 const index = type === 'min' ? 0 : 1;
327 if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; 327 if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0];
328 else newPos = this.checkLimits([this.minPosition, newPos])[1]; 328 else newPos = this.checkLimits([this.minPosition, newPos])[1];
329 - 329 +
330 const modulus = this.handleDecimal(newPos,this.step); 330 const modulus = this.handleDecimal(newPos,this.step);
331 const value = this.currentValue; 331 const value = this.currentValue;
332 value[index] = newPos - modulus; 332 value[index] = newPos - modulus;
333 this.currentValue = [...value]; 333 this.currentValue = [...value];
  334 +
334 if (!this.dragging) { 335 if (!this.dragging) {
335 if (this.currentValue[index] !== this.oldValue[index]) { 336 if (this.currentValue[index] !== this.oldValue[index]) {
336 this.emitChange(); 337 this.emitChange();