From ef7c28c7675641a4d7a863624040d79494f8ebc6 Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 3 Nov 2025 09:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=B3=E8=B7=83=E5=BC=8F=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=EF=BC=8C=E6=9A=82=E4=B8=8D=E5=B9=B3=E6=BB=91?= =?UTF-8?q?=EF=BC=8C=E8=A7=82=E6=84=9F=E5=B0=9A=E5=8F=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index a973434..413e1d6 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -301,19 +301,20 @@ const resetToCenter = () => { setTimeout(() => { isAnimating.value = false; - }, 1000); + }, 300); // 与 transition 时间一致(0.3s) }; // 滑动到前一天的位置(动画完成后更新日期) const slideToPreviousDay = () => { isAnimating.value = true; // 从当前位置继续滑动到前一天的完整位置(-screenWidth * 2) - // const targetX = -screenWidth.value*2; - // translateX.value = targetX; + const targetX = -screenWidth.value; + translateX.value = targetX; + // 等待动画完成(300ms,与 transition 时间一致) setTimeout(() => { // 滑动动画完成后,先暂时禁用 transition - // isAnimating.value = false; + isAnimating.value = false; // 在下一帧更新日期和重置位置(确保没有 transition 动画) setTimeout(() => { @@ -327,18 +328,18 @@ const slideToPreviousDay = () => { baseTranslateX.value = -screenWidth.value; console.log(`日期切换:上一天,新日期:${selectedDate.value}`); - }, 16); // 一帧的时间,确保 transition 已禁用 - }, 1000); - isAnimating.value = false; + }, 0); // 一帧的时间,确保 transition 已禁用 + }, 300); // 与 transition 时间一致(0.3s) }; // 滑动到后一天的位置(动画完成后更新日期) const slideToNextDay = () => { isAnimating.value = true; // 从当前位置继续滑动到后一天的完整位置(0) - // const targetX = 0; - // translateX.value = targetX; + const targetX = -screenWidth.value; + translateX.value = targetX; + // 等待动画完成(300ms,与 transition 时间一致) setTimeout(() => { // 滑动动画完成后,先暂时禁用 transition isAnimating.value = false; @@ -356,7 +357,7 @@ const slideToNextDay = () => { console.log(`日期切换:下一天,新日期:${selectedDate.value}`); }, 16); // 一帧的时间,确保 transition 已禁用 - }, 300); + }, 300); // 与 transition 时间一致(0.3s) }; // 监听日期变化,重置位置