Skip to content

Commit

Permalink
修正 "横着拿iPad 玩竖屏微信小游戏" 时, safeArea错误的问题. (#224)
Browse files Browse the repository at this point in the history
其他 小游戏平台,  以及其他 pad 没有测试 和 修改. 请 cocos官方去验证核实一下吧.

主要原因是.  微信小游戏上 不能用  windowWidth/windowHeight 来判断是不是landscape , 要用 screenWidth/screenHeight .
  • Loading branch information
finscn committed Mar 1, 2021
1 parent 8e5bd5f commit 385d38d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions platforms/wechat/wrapper/unify.js
Expand Up @@ -6,7 +6,12 @@ if (window.__globalAdapter) {
let systemInfo = wx.getSystemInfoSync();
let windowWidth = systemInfo.windowWidth;
let windowHeight = systemInfo.windowHeight;
let isLandscape = windowWidth > windowHeight;

let screenWidth = systemInfo.screenWidth;
let screenHeight = systemInfo.screenHeight;
let orientation = systemInfo.deviceOrientation;
let isLandscape = orientation ? (orientation === "landscape"): (screenWidth > screenHeight);

globalAdapter.isSubContext = (wx.getOpenDataContext === undefined);
globalAdapter.isDevTool = (systemInfo.platform === 'devtools');
utils.cloneMethod(globalAdapter, wx, 'getSystemInfoSync');
Expand Down Expand Up @@ -131,4 +136,4 @@ if (window.__globalAdapter) {
}
return { top, left, bottom, right, width, height };
}
}
}

0 comments on commit 385d38d

Please sign in to comment.