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