Commit 92b0539a076190514f723f9f2295fc4e3d83bb83
Committed by
GitHub
Merge pull request #2977 from SergioCrisostomo/fix-slider-onchange
Emit change on pointer up also
Showing
1 changed file
with
8 additions
and
3 deletions
Show diff stats
src/components/slider/slider.vue
@@ -240,6 +240,7 @@ | @@ -240,6 +240,7 @@ | ||
240 | if (this.dragging) { | 240 | if (this.dragging) { |
241 | this.dragging = false; | 241 | this.dragging = false; |
242 | this.$refs[`${this.pointerDown}Tooltip`].visible = false; | 242 | this.$refs[`${this.pointerDown}Tooltip`].visible = false; |
243 | + this.emitChange(); | ||
243 | } | 244 | } |
244 | 245 | ||
245 | this.pointerDown = ''; | 246 | this.pointerDown = ''; |
@@ -261,14 +262,18 @@ | @@ -261,14 +262,18 @@ | ||
261 | 262 | ||
262 | if (!this.dragging) { | 263 | if (!this.dragging) { |
263 | if (this.currentValue[index] !== this.oldValue[index]) { | 264 | if (this.currentValue[index] !== this.oldValue[index]) { |
264 | - const exportValue = this.range ? this.currentValue : this.currentValue[0]; | ||
265 | - this.$emit('on-change', exportValue); | ||
266 | - this.dispatch('FormItem', 'on-form-change', exportValue); | 265 | + this.emitChange(); |
267 | this.oldValue[index] = this.currentValue[index]; | 266 | this.oldValue[index] = this.currentValue[index]; |
268 | } | 267 | } |
269 | } | 268 | } |
270 | }, | 269 | }, |
271 | 270 | ||
271 | + emitChange(){ | ||
272 | + const exportValue = this.range ? this.currentValue : this.currentValue[0]; | ||
273 | + this.$emit('on-change', exportValue); | ||
274 | + this.dispatch('FormItem', 'on-form-change', exportValue); | ||
275 | + }, | ||
276 | + | ||
272 | sliderClick (event) { | 277 | sliderClick (event) { |
273 | if (this.disabled) return; | 278 | if (this.disabled) return; |
274 | const currentX = this.getPointerX(event); | 279 | const currentX = this.getPointerX(event); |