From 536b285c8e5dc9ee76d83fcfa4233cc8d92bf100 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 16 Aug 2021 15:24:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E6=97=B6scroll=20handler=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/components/scroll-view/index.vue | 119 +++++++++--------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/src/core/view/components/scroll-view/index.vue b/src/core/view/components/scroll-view/index.vue index d5dced152a..585cc6d3d0 100644 --- a/src/core/view/components/scroll-view/index.vue +++ b/src/core/view/components/scroll-view/index.vue @@ -465,70 +465,67 @@ export default { } }, _handleScroll: function ($event) { - if (!($event.timeStamp - this._lastScrollTime < 20)) { - this._lastScrollTime = $event.timeStamp - const target = $event.target - this.$trigger('scroll', $event, { - scrollLeft: target.scrollLeft, - scrollTop: target.scrollTop, - scrollHeight: target.scrollHeight, - scrollWidth: target.scrollWidth, - deltaX: this.lastScrollLeft - target.scrollLeft, - deltaY: this.lastScrollTop - target.scrollTop - }) - if (this.scrollY) { - if ( - target.scrollTop <= this.upperThresholdNumber && - this.lastScrollTop - target.scrollTop > 0 && - $event.timeStamp - this.lastScrollToUpperTime > 200 - ) { - this.$trigger('scrolltoupper', $event, { - direction: 'top' - }) - this.lastScrollToUpperTime = $event.timeStamp - } - if ( - target.scrollTop + - target.offsetHeight + - this.lowerThresholdNumber >= - target.scrollHeight && - this.lastScrollTop - target.scrollTop < 0 && - $event.timeStamp - this.lastScrollToLowerTime > 200 - ) { - this.$trigger('scrolltolower', $event, { - direction: 'bottom' - }) - this.lastScrollToLowerTime = $event.timeStamp - } + const target = $event.target + this.$trigger('scroll', $event, { + scrollLeft: target.scrollLeft, + scrollTop: target.scrollTop, + scrollHeight: target.scrollHeight, + scrollWidth: target.scrollWidth, + deltaX: this.lastScrollLeft - target.scrollLeft, + deltaY: this.lastScrollTop - target.scrollTop + }) + if (this.scrollY) { + if ( + target.scrollTop <= this.upperThresholdNumber && + this.lastScrollTop - target.scrollTop > 0 && + $event.timeStamp - this.lastScrollToUpperTime > 200 + ) { + this.$trigger('scrolltoupper', $event, { + direction: 'top' + }) + this.lastScrollToUpperTime = $event.timeStamp } - if (this.scrollX) { - if ( - target.scrollLeft <= this.upperThresholdNumber && - this.lastScrollLeft - target.scrollLeft > 0 && - $event.timeStamp - this.lastScrollToUpperTime > 200 - ) { - this.$trigger('scrolltoupper', $event, { - direction: 'left' - }) - this.lastScrollToUpperTime = $event.timeStamp - } - if ( - target.scrollLeft + - target.offsetWidth + - this.lowerThresholdNumber >= - target.scrollWidth && - this.lastScrollLeft - target.scrollLeft < 0 && - $event.timeStamp - this.lastScrollToLowerTime > 200 - ) { - this.$trigger('scrolltolower', $event, { - direction: 'right' - }) - this.lastScrollToLowerTime = $event.timeStamp - } + if ( + target.scrollTop + + target.offsetHeight + + this.lowerThresholdNumber >= + target.scrollHeight && + this.lastScrollTop - target.scrollTop < 0 && + $event.timeStamp - this.lastScrollToLowerTime > 200 + ) { + this.$trigger('scrolltolower', $event, { + direction: 'bottom' + }) + this.lastScrollToLowerTime = $event.timeStamp + } + } + if (this.scrollX) { + if ( + target.scrollLeft <= this.upperThresholdNumber && + this.lastScrollLeft - target.scrollLeft > 0 && + $event.timeStamp - this.lastScrollToUpperTime > 200 + ) { + this.$trigger('scrolltoupper', $event, { + direction: 'left' + }) + this.lastScrollToUpperTime = $event.timeStamp + } + if ( + target.scrollLeft + + target.offsetWidth + + this.lowerThresholdNumber >= + target.scrollWidth && + this.lastScrollLeft - target.scrollLeft < 0 && + $event.timeStamp - this.lastScrollToLowerTime > 200 + ) { + this.$trigger('scrolltolower', $event, { + direction: 'right' + }) + this.lastScrollToLowerTime = $event.timeStamp } - this.lastScrollTop = target.scrollTop - this.lastScrollLeft = target.scrollLeft } + this.lastScrollTop = target.scrollTop + this.lastScrollLeft = target.scrollLeft }, _scrollTopChanged: function (val) { if (this.scrollY) { -- GitLab