feat(Home): 添加横向滑动提示并优化交互
在法会流程部分添加横向滑动提示,帮助用户发现可滑动功能 添加触摸和滚动事件监听,用户交互后自动隐藏提示 优化样式和动画效果,提升用户体验
Showing
2 changed files
with
83 additions
and
0 deletions
scripts/需要挂大VPN同步
0 → 100644
File mode changed
| ... | @@ -31,6 +31,12 @@ | ... | @@ -31,6 +31,12 @@ |
| 31 | <img src="https://cdn.ipadbiz.cn/stdj/images/home/%E6%B3%95%E6%9C%83%E6%B5%81%E7%A8%8B@2x.png" alt="法会流程" /> | 31 | <img src="https://cdn.ipadbiz.cn/stdj/images/home/%E6%B3%95%E6%9C%83%E6%B5%81%E7%A8%8B@2x.png" alt="法会流程" /> |
| 32 | </div> | 32 | </div> |
| 33 | 33 | ||
| 34 | + <!-- 横向滑动提示:放在标题与流程步骤之间,清晰可读 --> | ||
| 35 | + <div v-show="showSwipeHint" class="swipe-hint"> | ||
| 36 | + <span class="swipe-icon">⇆</span> | ||
| 37 | + <span class="swipe-text">左右滑动查看更多</span> | ||
| 38 | + </div> | ||
| 39 | + | ||
| 34 | <!-- 流程步骤 --> | 40 | <!-- 流程步骤 --> |
| 35 | <div class="process-container"> | 41 | <div class="process-container"> |
| 36 | <!-- 麻绳背景 --> | 42 | <!-- 麻绳背景 --> |
| ... | @@ -335,6 +341,15 @@ const mastersList = ref([]) | ... | @@ -335,6 +341,15 @@ const mastersList = ref([]) |
| 335 | onMounted(async () => { | 341 | onMounted(async () => { |
| 336 | // 进入页面时立即回到顶部 | 342 | // 进入页面时立即回到顶部 |
| 337 | ensurePageScrollTop() | 343 | ensurePageScrollTop() |
| 344 | + // 初次进入展示滑动提示,不再自动隐藏 | ||
| 345 | + // 用户滑动或滚动后隐藏提示 | ||
| 346 | + nextTick(() => { | ||
| 347 | + const el = processStepsRef.value | ||
| 348 | + if (el) { | ||
| 349 | + el.addEventListener('touchmove', dismissSwipeHint, { passive: true }) | ||
| 350 | + el.addEventListener('scroll', dismissSwipeHint, { passive: true }) | ||
| 351 | + } | ||
| 352 | + }) | ||
| 338 | // 初始化不同屏幕下箭头bottom适配并监听resize | 353 | // 初始化不同屏幕下箭头bottom适配并监听resize |
| 339 | updateArrowBottomByScreen() | 354 | updateArrowBottomByScreen() |
| 340 | if (typeof window !== 'undefined') { | 355 | if (typeof window !== 'undefined') { |
| ... | @@ -393,6 +408,11 @@ onUnmounted(() => { | ... | @@ -393,6 +408,11 @@ onUnmounted(() => { |
| 393 | if (typeof window !== 'undefined') { | 408 | if (typeof window !== 'undefined') { |
| 394 | window.removeEventListener('resize', handleResize) | 409 | window.removeEventListener('resize', handleResize) |
| 395 | } | 410 | } |
| 411 | + const el = processStepsRef.value | ||
| 412 | + if (el) { | ||
| 413 | + el.removeEventListener('touchmove', dismissSwipeHint) | ||
| 414 | + el.removeEventListener('scroll', dismissSwipeHint) | ||
| 415 | + } | ||
| 396 | }) | 416 | }) |
| 397 | 417 | ||
| 398 | // 监听当前步骤变化,重新计算装饰线位置 | 418 | // 监听当前步骤变化,重新计算装饰线位置 |
| ... | @@ -644,6 +664,18 @@ const updateArrowBottomByScreen = () => { | ... | @@ -644,6 +664,18 @@ const updateArrowBottomByScreen = () => { |
| 644 | arrowBottomRem.value = -0.5 | 664 | arrowBottomRem.value = -0.5 |
| 645 | } | 665 | } |
| 646 | } | 666 | } |
| 667 | + | ||
| 668 | +// 是否显示横向滑动提示 | ||
| 669 | +const showSwipeHint = ref(true) | ||
| 670 | + | ||
| 671 | +/** | ||
| 672 | + * 隐藏横向滑动提示 | ||
| 673 | + * 说明:在用户首次滑动或滚动时隐藏,不再自动隐藏 | ||
| 674 | + * @returns {void} | ||
| 675 | + */ | ||
| 676 | +const dismissSwipeHint = () => { | ||
| 677 | + showSwipeHint.value = false | ||
| 678 | +} | ||
| 647 | </script> | 679 | </script> |
| 648 | 680 | ||
| 649 | <style scoped> | 681 | <style scoped> |
| ... | @@ -1078,6 +1110,57 @@ const updateArrowBottomByScreen = () => { | ... | @@ -1078,6 +1110,57 @@ const updateArrowBottomByScreen = () => { |
| 1078 | flex: 0 0 100%; | 1110 | flex: 0 0 100%; |
| 1079 | scroll-snap-align: start; | 1111 | scroll-snap-align: start; |
| 1080 | } | 1112 | } |
| 1113 | +/* 横向滑动提示样式:标题和流程之间的高对比胶囊提示 */ | ||
| 1114 | +.swipe-hint { | ||
| 1115 | + position: relative; | ||
| 1116 | + display: flex; | ||
| 1117 | + align-items: center; | ||
| 1118 | + justify-content: center; | ||
| 1119 | + gap: 0.35rem; | ||
| 1120 | + pointer-events: none; | ||
| 1121 | + margin: 0 auto 0.5rem; | ||
| 1122 | + padding: 0; | ||
| 1123 | + color: #985122; | ||
| 1124 | + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); | ||
| 1125 | + font-weight: 700; | ||
| 1126 | + opacity: 1; | ||
| 1127 | +} | ||
| 1128 | + | ||
| 1129 | +.swipe-icon { | ||
| 1130 | + font-size: 0.875rem; | ||
| 1131 | + line-height: 1; | ||
| 1132 | + animation: hint-slide 2.2s ease-in-out infinite; | ||
| 1133 | + filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15)); | ||
| 1134 | + color: #985122; | ||
| 1135 | +} | ||
| 1136 | + | ||
| 1137 | +.swipe-text { | ||
| 1138 | + font-size: 0.875rem; | ||
| 1139 | + font-weight: 700; | ||
| 1140 | + line-height: 1; | ||
| 1141 | + letter-spacing: 0.02rem; | ||
| 1142 | + color: #985122; | ||
| 1143 | +} | ||
| 1144 | + | ||
| 1145 | +/* 小屏幕适配 */ | ||
| 1146 | +@media (max-width: 30rem) { | ||
| 1147 | + .swipe-hint { | ||
| 1148 | + margin-bottom: 0.4rem; | ||
| 1149 | + } | ||
| 1150 | + .swipe-icon, | ||
| 1151 | + .swipe-text { | ||
| 1152 | + font-size: 0.8rem; | ||
| 1153 | + } | ||
| 1154 | +} | ||
| 1155 | + | ||
| 1156 | +/* 横向滑动动画:左右缓动,暗示可滑动 */ | ||
| 1157 | +@keyframes hint-slide { | ||
| 1158 | + 0% { transform: translateX(0); } | ||
| 1159 | + 25% { transform: translateX(-0.25rem); } | ||
| 1160 | + 50% { transform: translateX(0); } | ||
| 1161 | + 75% { transform: translateX(0.25rem); } | ||
| 1162 | + 100% { transform: translateX(0); } | ||
| 1163 | +} | ||
| 1081 | 1164 | ||
| 1082 | /* 单个流程步骤 */ | 1165 | /* 单个流程步骤 */ |
| 1083 | .process-step { | 1166 | .process-step { | ... | ... |
-
Please register or login to post a comment