diff --git a/core/core-frontend/src/views/chart/components/editor/index.vue b/core/core-frontend/src/views/chart/components/editor/index.vue index 1e1a7c892f..4d33b4055e 100644 --- a/core/core-frontend/src/views/chart/components/editor/index.vue +++ b/core/core-frontend/src/views/chart/components/editor/index.vue @@ -1983,6 +1983,30 @@ const deleteChartFieldItem = id => { fieldLoading.value = false }) } + +let directionTop = 0 +const scrollToTop = debounce(() => { + chartStyleRef.value.setScrollTop(directionTop) + directionTop = 0 +}, 10) + +const chartStyleRef = ref() +const chartStyleScroll = (val: any) => { + if (chartStyleRef.value) { + if (directionTop === 0) { + directionTop = val.scrollTop + } + if (val.scrollTop - directionTop > 0) { + // 向下滚 + directionTop = val.scrollTop - 1 + scrollToTop() + } else if (val.scrollTop === 0) { + // 向上滚 + directionTop = 1 + scrollToTop() + } + } +}