From 666bed7aea118c9cbfb186da50837c70269d18ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 7 May 2021 23:18:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BB=9A=E5=8A=A8=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scroll/index.wc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/scroll/index.wc b/src/scroll/index.wc index 84f956d..d089f9e 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -275,7 +275,7 @@ export default class Scroll { }) // 鼠标滚动事件 - this._scrollFn = $.bind(this.__BOX__, 'scroll', ev => { + this._scrollFn = $.catch(this.__BOX__, 'scroll', ev => { // 拖拽时忽略滚动事件 if (this._active) { return @@ -298,7 +298,6 @@ export default class Scroll { if (xBar === 0 && yBar === 0) { return } - console.log(currTop, currLeft) // if (axis === 'y' || axis === 'xy') { @@ -309,15 +308,13 @@ export default class Scroll { fixedY = fixedY >> 0 - if (fixedY === thumbY) { - return - } + if (fixedY !== thumbY) { + this.state.thumbY = fixedY + this.__Y__.style.transform = `translateY(${fixedY}px)` - this.state.thumbY = fixedY - this.__Y__.style.transform = `translateY(${fixedY}px)` - - if (Math.abs(fixedY - thumbY) > this.props.distance) { - this._fireReachEnd(fixedY > thumbY ? 'reach-bottom' : 'reach-top') + if (Math.abs(fixedY - thumbY) > this.props.distance) { + this._fireReachEnd(fixedY > thumbY ? 'reach-bottom' : 'reach-top') + } } } } @@ -330,12 +327,10 @@ export default class Scroll { fixedX = fixedX >> 0 - if (fixedX === thumbX) { - return + if (fixedX !== thumbX) { + this.state.thumbX = fixedX + this.__X__.style.transform = `translateX(${fixedX}px)` } - - this.state.thumbX = fixedX - this.__X__.style.transform = `translateX(${fixedX}px)` } }