修复 Slider 滑动按钮单击时数值跳动 issue

https://github.com/iview/iview/issues/1354
This commit is contained in:
oustn 2017-07-14 11:32:44 +08:00 committed by GitHub
parent da17044c8d
commit ce4c0faafc

View file

@ -285,11 +285,12 @@
on(window, 'mouseup', this.onSingleDragEnd); on(window, 'mouseup', this.onSingleDragEnd);
}, },
onSingleDragStart (event) { onSingleDragStart (event) {
this.dragging = true; this.dragging = false;
this.startX = event.clientX; this.startX = event.clientX;
this.startPos = parseInt(this.singlePosition, 10); this.startPos = parseInt(this.singlePosition, 10);
}, },
onSingleDragging (event) { onSingleDragging (event) {
this.dragging = true;
if (this.dragging) { if (this.dragging) {
this.$refs.tooltip.visible = true; this.$refs.tooltip.visible = true;
this.currentX = event.clientX; this.currentX = event.clientX;
@ -305,9 +306,9 @@
this.changeSinglePosition(this.newPos); this.changeSinglePosition(this.newPos);
// window.removeEventListener('mousemove', this.onSingleDragging); // window.removeEventListener('mousemove', this.onSingleDragging);
// window.removeEventListener('mouseup', this.onSingleDragEnd); // window.removeEventListener('mouseup', this.onSingleDragEnd);
}
off(window, 'mousemove', this.onSingleDragging); off(window, 'mousemove', this.onSingleDragging);
off(window, 'mouseup', this.onSingleDragEnd); off(window, 'mouseup', this.onSingleDragEnd);
}
}, },
changeSinglePosition (newPos) { changeSinglePosition (newPos) {
if (newPos < 0) { if (newPos < 0) {
@ -348,11 +349,12 @@
on(window, 'mouseup', this.onFirstDragEnd); on(window, 'mouseup', this.onFirstDragEnd);
}, },
onFirstDragStart (event) { onFirstDragStart (event) {
this.firstDragging = true; this.firstDragging = false;
this.startX = event.clientX; this.startX = event.clientX;
this.startPos = parseInt(this.firstPosition, 10); this.startPos = parseInt(this.firstPosition, 10);
}, },
onFirstDragging (event) { onFirstDragging (event) {
this.firstDragging = true;
if (this.firstDragging) { if (this.firstDragging) {
this.$refs.tooltip.visible = true; this.$refs.tooltip.visible = true;
this.currentX = event.clientX; this.currentX = event.clientX;
@ -368,9 +370,9 @@
this.changeFirstPosition(this.newPos); this.changeFirstPosition(this.newPos);
// window.removeEventListener('mousemove', this.onFirstDragging); // window.removeEventListener('mousemove', this.onFirstDragging);
// window.removeEventListener('mouseup', this.onFirstDragEnd); // window.removeEventListener('mouseup', this.onFirstDragEnd);
}
off(window, 'mousemove', this.onFirstDragging); off(window, 'mousemove', this.onFirstDragging);
off(window, 'mouseup', this.onFirstDragEnd); off(window, 'mouseup', this.onFirstDragEnd);
}
}, },
changeFirstPosition (newPos) { changeFirstPosition (newPos) {
if (newPos < 0) { if (newPos < 0) {
@ -405,11 +407,12 @@
on(window, 'mouseup', this.onSecondDragEnd); on(window, 'mouseup', this.onSecondDragEnd);
}, },
onSecondDragStart (event) { onSecondDragStart (event) {
this.secondDragging = true; this.secondDragging = false;
this.startX = event.clientX; this.startX = event.clientX;
this.startPos = parseInt(this.secondPosition, 10); this.startPos = parseInt(this.secondPosition, 10);
}, },
onSecondDragging (event) { onSecondDragging (event) {
this.secondDragging = true;
if (this.secondDragging) { if (this.secondDragging) {
this.$refs.tooltip2.visible = true; this.$refs.tooltip2.visible = true;
this.currentX = event.clientX; this.currentX = event.clientX;
@ -425,9 +428,9 @@
this.changeSecondPosition(this.newPos); this.changeSecondPosition(this.newPos);
// window.removeEventListener('mousemove', this.onSecondDragging); // window.removeEventListener('mousemove', this.onSecondDragging);
// window.removeEventListener('mouseup', this.onSecondDragEnd); // window.removeEventListener('mouseup', this.onSecondDragEnd);
}
off(window, 'mousemove', this.onSecondDragging); off(window, 'mousemove', this.onSecondDragging);
off(window, 'mouseup', this.onSecondDragEnd); off(window, 'mouseup', this.onSecondDragEnd);
}
}, },
changeSecondPosition (newPos) { changeSecondPosition (newPos) {
if (newPos > 100) { if (newPos > 100) {