Browse Source

优化搜索区域平滑隐藏效果,修复突然收缩问题

pull/1/head
Trae AI 2 months ago
parent
commit
a7b3d0b4c3
  1. 2
      pages/index/index.js
  2. 5
      pages/index/index.wxss

2
pages/index/index.js

@ -832,7 +832,7 @@ Page({
if (scrollTop > 50) { if (scrollTop > 50) {
// 当滚动距离超过50rpx时,开始逐渐隐藏 // 当滚动距离超过50rpx时,开始逐渐隐藏
const hideProgress = Math.min((scrollTop - 50) / 100, 1); // 0-1的隐藏进度 const hideProgress = Math.min((scrollTop - 50) / 150, 1); // 0-1的隐藏进度,延长隐藏过程
searchSectionOpacity = 1 - hideProgress; searchSectionOpacity = 1 - hideProgress;
searchSectionTransform = -20 * hideProgress; searchSectionTransform = -20 * hideProgress;

5
pages/index/index.wxss

@ -27,14 +27,17 @@ page {
overflow: hidden; overflow: hidden;
transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
will-change: opacity, transform, padding, margin, max-height; will-change: opacity, transform, padding, margin, max-height;
max-height: 200rpx; /* 设置一个具体的最大高度,确保过渡效果生效 */
} }
/* 顶部搜索区域完全隐藏状态 - 用于收缩高度 */ /* 顶部搜索区域完全隐藏状态 - 用于平滑收缩高度 */
.top-hidden { .top-hidden {
max-height: 0; max-height: 0;
padding: 0; padding: 0;
margin-bottom: 0; margin-bottom: 0;
pointer-events: none; pointer-events: none;
opacity: 0;
transform: translateY(-100%);
} }
/* 标题样式 */ /* 标题样式 */

Loading…
Cancel
Save