From c076fd004f1ff5c28cf4d923d43af28ace9f1156 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Mon, 29 Nov 2021 18:27:07 +0800 Subject: [PATCH] chore: scroll-view --- .../view/components/scroll-view/index.vue | 50 +++++-------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/core/view/components/scroll-view/index.vue b/src/core/view/components/scroll-view/index.vue index 22a922a16..6eb72aced 100644 --- a/src/core/view/components/scroll-view/index.vue +++ b/src/core/view/components/scroll-view/index.vue @@ -86,11 +86,13 @@ import { disableScrollBounce } from 'uni-platform/helpers/scroll' -const passiveOptions = supportsPassive - ? { - passive: true - } - : false +const passive = (passive = true) => + supportsPassive + ? { + passive + } + : false +const passiveOptions = passive() // const PULLING = 'pulling' // const REFRESHING = 'refreshing' @@ -322,34 +324,10 @@ export default { self._setRefreshState('refresherabort') } } - this.$refs.main.addEventListener( - 'touchstart', - this.__handleTouchStart, - passiveOptions - ) - this.$refs.main.addEventListener( - 'touchmove', - this.__handleTouchMove, - supportsPassive - ? { - passive: false - } - : false - ) - this.$refs.main.addEventListener( - 'scroll', - this.__handleScroll, - supportsPassive - ? { - passive: false - } - : false - ) - this.$refs.main.addEventListener( - 'touchend', - this.__handleTouchEnd, - passiveOptions - ) + this.$refs.main.addEventListener('touchstart', this.__handleTouchStart, passiveOptions) + this.$refs.main.addEventListener('touchmove', this.__handleTouchMove, passive(false)) + this.$refs.main.addEventListener('scroll', this.__handleScroll, passive(false)) + this.$refs.main.addEventListener('touchend', this.__handleTouchEnd, passiveOptions) initScrollBounce() }, activated () { @@ -371,11 +349,7 @@ export default { this.$refs.main.removeEventListener( 'scroll', this.__handleScroll, - supportsPassive - ? { - passive: false - } - : false + passive(false) ) this.$refs.main.removeEventListener( 'touchend', -- GitLab