Commit ce45917bde1523129e168389ca7ecc08a77fd90a
1 parent
1dad8a57
update Slider
Showing
1 changed file
with
25 additions
and
12 deletions
Show diff stats
src/components/slider/slider.vue
@@ -48,6 +48,7 @@ | @@ -48,6 +48,7 @@ | ||
48 | import InputNumber from '../../components/input-number/input-number.vue'; | 48 | import InputNumber from '../../components/input-number/input-number.vue'; |
49 | import Tooltip from '../../components/tooltip/tooltip.vue'; | 49 | import Tooltip from '../../components/tooltip/tooltip.vue'; |
50 | import { getStyle, oneOf } from '../../utils/assist'; | 50 | import { getStyle, oneOf } from '../../utils/assist'; |
51 | + import { on, off } from '../../utils'; | ||
51 | import Emitter from '../../mixins/emitter'; | 52 | import Emitter from '../../mixins/emitter'; |
52 | 53 | ||
53 | const prefixCls = 'ivu-slider'; | 54 | const prefixCls = 'ivu-slider'; |
@@ -278,8 +279,10 @@ | @@ -278,8 +279,10 @@ | ||
278 | if (this.disabled) return; | 279 | if (this.disabled) return; |
279 | event.preventDefault(); | 280 | event.preventDefault(); |
280 | this.onSingleDragStart(event); | 281 | this.onSingleDragStart(event); |
281 | - window.addEventListener('mousemove', this.onSingleDragging); | ||
282 | - window.addEventListener('mouseup', this.onSingleDragEnd); | 282 | +// window.addEventListener('mousemove', this.onSingleDragging); |
283 | +// window.addEventListener('mouseup', this.onSingleDragEnd); | ||
284 | + on(window, 'mousemove', this.onSingleDragging); | ||
285 | + on(window, 'mouseup', this.onSingleDragEnd); | ||
283 | }, | 286 | }, |
284 | onSingleDragStart (event) { | 287 | onSingleDragStart (event) { |
285 | this.dragging = true; | 288 | this.dragging = true; |
@@ -300,8 +303,10 @@ | @@ -300,8 +303,10 @@ | ||
300 | this.dragging = false; | 303 | this.dragging = false; |
301 | this.$refs.tooltip.visible = false; | 304 | this.$refs.tooltip.visible = false; |
302 | this.changeSinglePosition(this.newPos); | 305 | this.changeSinglePosition(this.newPos); |
303 | - window.removeEventListener('mousemove', this.onSingleDragging); | ||
304 | - window.removeEventListener('mouseup', this.onSingleDragEnd); | 306 | +// window.removeEventListener('mousemove', this.onSingleDragging); |
307 | +// window.removeEventListener('mouseup', this.onSingleDragEnd); | ||
308 | + off(window, 'mousemove', this.onSingleDragging); | ||
309 | + off(window, 'mouseup', this.onSingleDragEnd); | ||
305 | } | 310 | } |
306 | }, | 311 | }, |
307 | changeSinglePosition (newPos) { | 312 | changeSinglePosition (newPos) { |
@@ -337,8 +342,10 @@ | @@ -337,8 +342,10 @@ | ||
337 | if (this.disabled) return; | 342 | if (this.disabled) return; |
338 | event.preventDefault(); | 343 | event.preventDefault(); |
339 | this.onFirstDragStart(event); | 344 | this.onFirstDragStart(event); |
340 | - window.addEventListener('mousemove', this.onFirstDragging); | ||
341 | - window.addEventListener('mouseup', this.onFirstDragEnd); | 345 | +// window.addEventListener('mousemove', this.onFirstDragging); |
346 | +// window.addEventListener('mouseup', this.onFirstDragEnd); | ||
347 | + on(window, 'mousemove', this.onFirstDragging); | ||
348 | + on(window, 'mouseup', this.onFirstDragEnd); | ||
342 | }, | 349 | }, |
343 | onFirstDragStart (event) { | 350 | onFirstDragStart (event) { |
344 | this.firstDragging = true; | 351 | this.firstDragging = true; |
@@ -359,8 +366,10 @@ | @@ -359,8 +366,10 @@ | ||
359 | this.firstDragging = false; | 366 | this.firstDragging = false; |
360 | this.$refs.tooltip.visible = false; | 367 | this.$refs.tooltip.visible = false; |
361 | this.changeFirstPosition(this.newPos); | 368 | this.changeFirstPosition(this.newPos); |
362 | - window.removeEventListener('mousemove', this.onFirstDragging); | ||
363 | - window.removeEventListener('mouseup', this.onFirstDragEnd); | 369 | +// window.removeEventListener('mousemove', this.onFirstDragging); |
370 | +// window.removeEventListener('mouseup', this.onFirstDragEnd); | ||
371 | + off(window, 'mousemove', this.onFirstDragging); | ||
372 | + off(window, 'mouseup', this.onFirstDragEnd); | ||
364 | } | 373 | } |
365 | }, | 374 | }, |
366 | changeFirstPosition (newPos) { | 375 | changeFirstPosition (newPos) { |
@@ -390,8 +399,10 @@ | @@ -390,8 +399,10 @@ | ||
390 | if (this.disabled) return; | 399 | if (this.disabled) return; |
391 | event.preventDefault(); | 400 | event.preventDefault(); |
392 | this.onSecondDragStart(event); | 401 | this.onSecondDragStart(event); |
393 | - window.addEventListener('mousemove', this.onSecondDragging); | ||
394 | - window.addEventListener('mouseup', this.onSecondDragEnd); | 402 | +// window.addEventListener('mousemove', this.onSecondDragging); |
403 | +// window.addEventListener('mouseup', this.onSecondDragEnd); | ||
404 | + on(window, 'mousemove', this.onSecondDragging); | ||
405 | + on(window, 'mouseup', this.onSecondDragEnd); | ||
395 | }, | 406 | }, |
396 | onSecondDragStart (event) { | 407 | onSecondDragStart (event) { |
397 | this.secondDragging = true; | 408 | this.secondDragging = true; |
@@ -412,8 +423,10 @@ | @@ -412,8 +423,10 @@ | ||
412 | this.secondDragging = false; | 423 | this.secondDragging = false; |
413 | this.$refs.tooltip2.visible = false; | 424 | this.$refs.tooltip2.visible = false; |
414 | this.changeSecondPosition(this.newPos); | 425 | this.changeSecondPosition(this.newPos); |
415 | - window.removeEventListener('mousemove', this.onSecondDragging); | ||
416 | - window.removeEventListener('mouseup', this.onSecondDragEnd); | 426 | +// window.removeEventListener('mousemove', this.onSecondDragging); |
427 | +// window.removeEventListener('mouseup', this.onSecondDragEnd); | ||
428 | + off(window, 'mousemove', this.onSecondDragging); | ||
429 | + off(window, 'mouseup', this.onSecondDragEnd); | ||
417 | } | 430 | } |
418 | }, | 431 | }, |
419 | changeSecondPosition (newPos) { | 432 | changeSecondPosition (newPos) { |