From fd08d25ccf3d52082d8d5666ad16e11c7e86405e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E4=BC=A0=E9=BE=99?= Date: Sat, 9 Jul 2022 15:03:39 +0800 Subject: [PATCH] perf: optimize ScrooX component. --- src/components/common/ScrollX.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/common/ScrollX.vue b/src/components/common/ScrollX.vue index c0c823e..1161fc7 100644 --- a/src/components/common/ScrollX.vue +++ b/src/components/common/ScrollX.vue @@ -37,7 +37,10 @@ const wrapper = ref(null) const isOverflow = ref(false) const refreshIsOverflow = debounce(() => { - isOverflow.value = content.value.offsetWidth > wrapper.value.offsetWidth + const wrapperWidth = wrapper.value.offsetWidth + const contentWidth = content.value.offsetWidth + isOverflow.value = contentWidth > wrapperWidth + resetTranslateX(wrapperWidth, contentWidth) }, 200) function handleMouseWheel(e) {