|
|
|
@ -25,8 +25,6 @@ Page({ |
|
|
|
searchSectionVisible: true, |
|
|
|
lastScrollTop: 0, |
|
|
|
isScrollLocked: false, |
|
|
|
searchSectionOpacity: 1, |
|
|
|
searchSectionTransform: 0, |
|
|
|
isSearchBarFullyHidden: false, |
|
|
|
|
|
|
|
// 回到顶部按钮
|
|
|
|
@ -826,33 +824,23 @@ Page({ |
|
|
|
onScroll: function(e) { |
|
|
|
const { scrollTop } = e.detail; |
|
|
|
|
|
|
|
let searchSectionOpacity = 1; |
|
|
|
let searchSectionTransform = 0; |
|
|
|
// 只控制搜索区域的完全显示/隐藏状态,使用CSS类统一控制过渡效果
|
|
|
|
// 简化逻辑,避免iOS上的兼容性问题
|
|
|
|
let isSearchBarFullyHidden = false; |
|
|
|
|
|
|
|
if (scrollTop > 50) { |
|
|
|
// 当滚动距离超过50rpx时,开始逐渐隐藏
|
|
|
|
const hideProgress = Math.min((scrollTop - 50) / 150, 1); // 0-1的隐藏进度,延长隐藏过程
|
|
|
|
searchSectionOpacity = 1 - hideProgress; |
|
|
|
searchSectionTransform = -20 * hideProgress; |
|
|
|
|
|
|
|
// 当隐藏进度达到100%时,添加完全隐藏类
|
|
|
|
if (hideProgress >= 1) { |
|
|
|
isSearchBarFullyHidden = true; |
|
|
|
} |
|
|
|
// 增加iOS兼容性处理,使用更简单的触发逻辑
|
|
|
|
if (scrollTop > 150) { |
|
|
|
// 当滚动距离超过150rpx时,完全隐藏搜索区域
|
|
|
|
isSearchBarFullyHidden = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 当滚动回到顶部时,重置所有状态
|
|
|
|
if (scrollTop <= 50) { |
|
|
|
searchSectionOpacity = 1; |
|
|
|
searchSectionTransform = 0; |
|
|
|
// 当滚动回到顶部时,显示搜索区域
|
|
|
|
if (scrollTop <= 100) { |
|
|
|
isSearchBarFullyHidden = false; |
|
|
|
} |
|
|
|
|
|
|
|
// 更新搜索框状态和样式
|
|
|
|
// 更新搜索框状态
|
|
|
|
this.setData({ |
|
|
|
searchSectionOpacity: searchSectionOpacity, |
|
|
|
searchSectionTransform: searchSectionTransform, |
|
|
|
isSearchBarFullyHidden: isSearchBarFullyHidden, |
|
|
|
lastScrollTop: scrollTop |
|
|
|
}); |
|
|
|
|