diff --git a/docs/api/system/info.md b/docs/api/system/info.md index b9795f1a0fd1b89ea3cc9869fab26e379a813d73..61fe281a8b01aab85d51ab012f97dd9f35813717 100644 --- a/docs/api/system/info.md +++ b/docs/api/system/info.md @@ -51,6 +51,7 @@ |locationEnabled | 地理位置的系统开关 |微信小程序| |wifiEnabled | Wi-Fi 的系统开关 |微信小程序| |safeArea|在竖屏正方向下的安全区域|5+App、H5、微信小程序| +|safeAreaInsets|在竖屏正方向下的安全区域插入位置(2.5.3+)|5+App、H5、微信小程序| **Tips** - 屏幕高度=状态栏高度+原生导航栏高度+可使用窗口高度+原生tabbar高度 @@ -68,6 +69,15 @@ |width |Number |安全区域的宽度,单位逻辑像素 | |height |Number |安全区域的高度,单位逻辑像素 | +**safeAreaInsets 的结构** + +|参数 |类型 |说明 | +|:- |:- |:- | +|left |Number |安全区域左侧插入位置 | +|right |Number |安全区域右侧插入位置 | +|top |Number |安全区顶部插入位置 | +|bottom |Number |安全区域底部插入位置 | + **示例** @@ -130,6 +140,7 @@ uni.getSystemInfo({ |locationEnabled | 地理位置的系统开关 |微信小程序| |wifiEnabled | Wi-Fi 的系统开关 |微信小程序| |safeArea|在竖屏正方向下的安全区域|5+App、H5、微信小程序| +|safeAreaInsets|在竖屏正方向下的安全区域插入位置(2.5.3+)|5+App、H5、微信小程序| **Tips** - 使用注意同上getSystemInfo @@ -145,6 +156,14 @@ uni.getSystemInfo({ |width |Number |安全区域的宽度,单位逻辑像素 | |height |Number |安全区域的高度,单位逻辑像素 | +**safeAreaInsets 的结构** + +|参数 |类型 |说明 | +|:- |:- |:- | +|left |Number |安全区域左侧插入位置 | +|right |Number |安全区域右侧插入位置 | +|top |Number |安全区顶部插入位置 | +|bottom |Number |安全区域底部插入位置 | **示例** diff --git a/src/core/helpers/hidpi.js b/src/core/helpers/hidpi.js index 88eae7d67612c9f8e7a91b6a013172d3932bf8da..0c131d1042b3ed645a63f5b3ce8102dad03f17ed 100644 --- a/src/core/helpers/hidpi.js +++ b/src/core/helpers/hidpi.js @@ -38,6 +38,24 @@ const ratioArgs = { } const proto = CanvasRenderingContext2D.prototype + +proto.drawImageByCanvas = (function (_super) { + return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { + if (!this.__hidpi__) { + return _super.apply(this, arguments) + } + srcx *= pixelRatio + srcy *= pixelRatio + srcw *= pixelRatio + srch *= pixelRatio + desx *= pixelRatio + desy *= pixelRatio + desw = isScale ? desw * pixelRatio : desw + desh = isScale ? desh * pixelRatio : desh + _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh) + } +})(proto.drawImage) + if (pixelRatio !== 1) { forEach(ratioArgs, function (value, key) { proto[key] = (function (_super) { @@ -141,23 +159,6 @@ if (pixelRatio !== 1) { })(proto.drawImage) } -proto.drawImageByCanvas = (function (_super) { - return function (canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { - if (!this.__hidpi__) { - return _super.apply(this, arguments) - } - srcx *= pixelRatio - srcy *= pixelRatio - srcw *= pixelRatio - srch *= pixelRatio - desx *= pixelRatio - desy *= pixelRatio - desw = isScale ? desw * pixelRatio : desw - desh = isScale ? desh * pixelRatio : desh - _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh) - } -})(proto.drawImage) - export function wrapper (canvas) { canvas.width = canvas.offsetWidth * pixelRatio canvas.height = canvas.offsetHeight * pixelRatio