diff --git a/src/components/HorizontalScrollView.vue b/src/components/HorizontalScrollView.vue index ca713419..a6cea184 100644 --- a/src/components/HorizontalScrollView.vue +++ b/src/components/HorizontalScrollView.vue @@ -7,11 +7,14 @@ const scrollListWrap = ref() as Ref // const showRightMask = ref(false) const showScrollMask = ref(true) -watch(() => settings.value.enableHorizontalScrolling, (newValue) => { - if (newValue) - scrollListWrap.value.addEventListener('wheel', handleMouseScroll) +watch([() => settings.value.enableHorizontalScrolling, scrollListWrap], ([enableHorizontalScrolling, scrollListWrap]) => { + if (!scrollListWrap) + return + + if (enableHorizontalScrolling) + scrollListWrap.addEventListener('wheel', handleMouseScroll) else - scrollListWrap.value.removeEventListener('wheel', handleMouseScroll) + scrollListWrap.removeEventListener('wheel', handleMouseScroll) }) onMounted(() => {