From 9c6ae1dd6046298c98228bfab6584f4ac123d5ad Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 22 Mar 2026 14:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E7=AD=BE=E5=B7=A6=E5=8F=B3=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=95=88=E6=9E=9C=E5=85=BC=E5=AE=B9=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8D=E4=BE=9D=E8=B5=96behavior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/components/TagsView/ScrollPane.vue | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue b/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue index dfcebd57..706fa2e0 100644 --- a/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue +++ b/ruoyi-ui/src/layout/components/TagsView/ScrollPane.vue @@ -28,8 +28,32 @@ export default { methods: { smoothScrollTo(target) { const $scrollWrapper = this.scrollWrapper - $scrollWrapper.scrollTo({ left: target, behavior: 'smooth' }) - setTimeout(() => this.$emit('updateArrows'), 350) + const start = $scrollWrapper.scrollLeft + const distance = target - start + const duration = 300 + let startTime = null + + function ease(t, b, c, d) { + t /= d / 2 + if (t < 1) return c / 2 * t * t + b + t-- + return -c / 2 * (t * (t - 2) - 1) + b + } + + const emit = this.$emit.bind(this) + function step(timestamp) { + if (!startTime) startTime = timestamp + const elapsed = timestamp - startTime + $scrollWrapper.scrollLeft = ease(elapsed, start, distance, duration) + if (elapsed < duration) { + requestAnimationFrame(step) + } else { + $scrollWrapper.scrollLeft = target + emit('updateArrows') + } + } + + requestAnimationFrame(step) }, handleScroll(e) { const eventDelta = e.wheelDelta || -e.deltaY * 40