Browse Source

简化侧边栏按钮边界检测逻辑

- 使用百分比计算边界,兼容所有设备
- 按钮活动范围:屏幕顶部10%到底部75%
- 移除复杂的safeArea判断,提高健壮性
pull/1/head
徐飞洋 2 months ago
parent
commit
793637f9e1
  1. 27
      pages/index/index.js

27
pages/index/index.js

@ -149,29 +149,16 @@ Page({
let newTop = this.data.sidebarBtnTop + diffY * 2;
const systemInfo = wx.getSystemInfoSync();
const screenHeight = systemInfo.screenHeight;
const safeArea = systemInfo.safeArea;
const screenHeight = systemInfo.screenHeight * 2;
const btnHeight = 90;
const margin = 20;
const tabBarHeight = 70;
let minTop, maxTop;
const minTop = screenHeight * 0.1;
const maxTop = screenHeight * 0.75;
if (safeArea) {
minTop = safeArea.top + margin;
maxTop = safeArea.bottom - btnHeight - margin - tabBarHeight;
} else {
minTop = margin;
maxTop = screenHeight - btnHeight - margin - tabBarHeight;
}
const minTopRpx = minTop * 2;
const maxTopRpx = maxTop * 2;
if (newTop < minTopRpx) {
newTop = minTopRpx;
} else if (newTop > maxTopRpx) {
newTop = maxTopRpx;
if (newTop < minTop) {
newTop = minTop;
} else if (newTop > maxTop) {
newTop = maxTop;
}
this.setData({

Loading…
Cancel
Save