Commit 59dbe5d565d8bc0683984f3ea1b9b77205f0049b
1 parent
9d275e38
update
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
src/components/scroll/scroll.vue
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | <script> |
| 23 | 23 | import throttle from 'lodash.throttle'; |
| 24 | 24 | import loader from './loading-component.vue'; |
| 25 | + import { on, off } from '../../utils/dom'; | |
| 25 | 26 | |
| 26 | 27 | const prefixCls = 'ivu-scroll'; |
| 27 | 28 | const dragConfig = { |
| ... | ... | @@ -159,7 +160,7 @@ |
| 159 | 160 | // if we remove the handler too soon the screen will bump |
| 160 | 161 | if (this.touchScroll) { |
| 161 | 162 | setTimeout(() => { |
| 162 | - window.removeEventListener('touchend', this.pointerUpHandler); | |
| 163 | + off(window, 'touchend', this.pointerUpHandler); | |
| 163 | 164 | this.$refs.scrollContainer.removeEventListener('touchmove', this.pointerMoveHandler); |
| 164 | 165 | this.touchScroll = false; |
| 165 | 166 | }, 500); |
| ... | ... | @@ -233,7 +234,7 @@ |
| 233 | 234 | this.$refs.scrollContainer.scrollTop = 5; |
| 234 | 235 | |
| 235 | 236 | this.pointerTouchDown = this.getTouchCoordinates(e); |
| 236 | - window.addEventListener('touchend', this.pointerUpHandler); | |
| 237 | + on(window, 'touchend', this.pointerUpHandler); | |
| 237 | 238 | this.$refs.scrollContainer.parentElement.addEventListener('touchmove', e => { |
| 238 | 239 | e.stopPropagation(); |
| 239 | 240 | this.pointerMoveHandler(e); |
| ... | ... | @@ -252,7 +253,6 @@ |
| 252 | 253 | if (!this.touchScroll) { |
| 253 | 254 | const wasDragged = Math.abs(yDiff) > dragConfig.minimumStartDragOffset; |
| 254 | 255 | if (wasDragged) this.touchScroll = true; |
| 255 | - else return; | |
| 256 | 256 | } |
| 257 | 257 | }, |
| 258 | 258 | |
| ... | ... | @@ -260,7 +260,7 @@ |
| 260 | 260 | this.pointerTouchDown = null; |
| 261 | 261 | } |
| 262 | 262 | }, |
| 263 | - created(){ | |
| 263 | + created() { | |
| 264 | 264 | this.handleScroll = throttle(this.onScroll, 150, {leading: false}); |
| 265 | 265 | this.pointerUpHandler = this.onPointerUp.bind(this); // because we need the same function to add and remove event handlers |
| 266 | 266 | this.pointerMoveHandler = throttle(this.onPointerMove, 50, {leading: false}); | ... | ... |