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 | 48 | import InputNumber from '../../components/input-number/input-number.vue'; |
| 49 | 49 | import Tooltip from '../../components/tooltip/tooltip.vue'; |
| 50 | 50 | import { getStyle, oneOf } from '../../utils/assist'; |
| 51 | + import { on, off } from '../../utils'; | |
| 51 | 52 | import Emitter from '../../mixins/emitter'; |
| 52 | 53 | |
| 53 | 54 | const prefixCls = 'ivu-slider'; |
| ... | ... | @@ -278,8 +279,10 @@ |
| 278 | 279 | if (this.disabled) return; |
| 279 | 280 | event.preventDefault(); |
| 280 | 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 | 287 | onSingleDragStart (event) { |
| 285 | 288 | this.dragging = true; |
| ... | ... | @@ -300,8 +303,10 @@ |
| 300 | 303 | this.dragging = false; |
| 301 | 304 | this.$refs.tooltip.visible = false; |
| 302 | 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 | 312 | changeSinglePosition (newPos) { |
| ... | ... | @@ -337,8 +342,10 @@ |
| 337 | 342 | if (this.disabled) return; |
| 338 | 343 | event.preventDefault(); |
| 339 | 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 | 350 | onFirstDragStart (event) { |
| 344 | 351 | this.firstDragging = true; |
| ... | ... | @@ -359,8 +366,10 @@ |
| 359 | 366 | this.firstDragging = false; |
| 360 | 367 | this.$refs.tooltip.visible = false; |
| 361 | 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 | 375 | changeFirstPosition (newPos) { |
| ... | ... | @@ -390,8 +399,10 @@ |
| 390 | 399 | if (this.disabled) return; |
| 391 | 400 | event.preventDefault(); |
| 392 | 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 | 407 | onSecondDragStart (event) { |
| 397 | 408 | this.secondDragging = true; |
| ... | ... | @@ -412,8 +423,10 @@ |
| 412 | 423 | this.secondDragging = false; |
| 413 | 424 | this.$refs.tooltip2.visible = false; |
| 414 | 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 | 432 | changeSecondPosition (newPos) { | ... | ... |