Browse Source

添加iOS安全区域兼容

- 使用safeArea计算iPhone刘海边距
- 保留百分比作为安卓备用方案
pull/1/head
徐飞洋 2 months ago
parent
commit
12db027a80
  1. 12
      pages/index/index.js

12
pages/index/index.js

@ -150,10 +150,18 @@ Page({
const systemInfo = wx.getSystemInfoSync(); const systemInfo = wx.getSystemInfoSync();
const screenHeight = systemInfo.screenHeight * 2; const screenHeight = systemInfo.screenHeight * 2;
const safeArea = systemInfo.safeArea;
const btnHeight = 90; const btnHeight = 90;
const minTop = screenHeight * 0.2; let minTop, maxTop;
const maxTop = screenHeight * 0.75;
if (safeArea && safeArea.top > 20) {
minTop = safeArea.top * 2 + 20;
maxTop = safeArea.bottom * 2 - btnHeight - 20;
} else {
minTop = screenHeight * 0.2;
maxTop = screenHeight * 0.6;
}
if (newTop < minTop) { if (newTop < minTop) {
newTop = minTop; newTop = minTop;

Loading…
Cancel
Save