Commit 57f920ff65e07b3b8aaf19be999baf3e9f7a0e98

Authored by Aresn
Committed by GitHub
2 parents d293cc5c b4e43426

Merge pull request #1355 from oustn/2.0

修复 Slider 滑动按钮单击时数值跳动 issue
Showing 1 changed file with 12 additions and 9 deletions   Show diff stats
src/components/slider/slider.vue
... ... @@ -285,11 +285,12 @@
285 285 on(window, 'mouseup', this.onSingleDragEnd);
286 286 },
287 287 onSingleDragStart (event) {
288   - this.dragging = true;
  288 + this.dragging = false;
289 289 this.startX = event.clientX;
290 290 this.startPos = parseInt(this.singlePosition, 10);
291 291 },
292 292 onSingleDragging (event) {
  293 + this.dragging = true;
293 294 if (this.dragging) {
294 295 this.$refs.tooltip.visible = true;
295 296 this.currentX = event.clientX;
... ... @@ -305,9 +306,9 @@
305 306 this.changeSinglePosition(this.newPos);
306 307 // window.removeEventListener('mousemove', this.onSingleDragging);
307 308 // window.removeEventListener('mouseup', this.onSingleDragEnd);
308   - off(window, 'mousemove', this.onSingleDragging);
309   - off(window, 'mouseup', this.onSingleDragEnd);
310 309 }
  310 + off(window, 'mousemove', this.onSingleDragging);
  311 + off(window, 'mouseup', this.onSingleDragEnd);
311 312 },
312 313 changeSinglePosition (newPos) {
313 314 if (newPos < 0) {
... ... @@ -348,11 +349,12 @@
348 349 on(window, 'mouseup', this.onFirstDragEnd);
349 350 },
350 351 onFirstDragStart (event) {
351   - this.firstDragging = true;
  352 + this.firstDragging = false;
352 353 this.startX = event.clientX;
353 354 this.startPos = parseInt(this.firstPosition, 10);
354 355 },
355 356 onFirstDragging (event) {
  357 + this.firstDragging = true;
356 358 if (this.firstDragging) {
357 359 this.$refs.tooltip.visible = true;
358 360 this.currentX = event.clientX;
... ... @@ -368,9 +370,9 @@
368 370 this.changeFirstPosition(this.newPos);
369 371 // window.removeEventListener('mousemove', this.onFirstDragging);
370 372 // window.removeEventListener('mouseup', this.onFirstDragEnd);
371   - off(window, 'mousemove', this.onFirstDragging);
372   - off(window, 'mouseup', this.onFirstDragEnd);
373 373 }
  374 + off(window, 'mousemove', this.onFirstDragging);
  375 + off(window, 'mouseup', this.onFirstDragEnd);
374 376 },
375 377 changeFirstPosition (newPos) {
376 378 if (newPos < 0) {
... ... @@ -405,11 +407,12 @@
405 407 on(window, 'mouseup', this.onSecondDragEnd);
406 408 },
407 409 onSecondDragStart (event) {
408   - this.secondDragging = true;
  410 + this.secondDragging = false;
409 411 this.startX = event.clientX;
410 412 this.startPos = parseInt(this.secondPosition, 10);
411 413 },
412 414 onSecondDragging (event) {
  415 + this.secondDragging = true;
413 416 if (this.secondDragging) {
414 417 this.$refs.tooltip2.visible = true;
415 418 this.currentX = event.clientX;
... ... @@ -425,9 +428,9 @@
425 428 this.changeSecondPosition(this.newPos);
426 429 // window.removeEventListener('mousemove', this.onSecondDragging);
427 430 // window.removeEventListener('mouseup', this.onSecondDragEnd);
428   - off(window, 'mousemove', this.onSecondDragging);
429   - off(window, 'mouseup', this.onSecondDragEnd);
430 431 }
  432 + off(window, 'mousemove', this.onSecondDragging);
  433 + off(window, 'mouseup', this.onSecondDragEnd);
431 434 },
432 435 changeSecondPosition (newPos) {
433 436 if (newPos > 100) {
... ...