提交 9947a97e 编写于 作者: fxy060608's avatar fxy060608

fix: upx 负数转换和正数不一致的问题

上级 31bcff7f
......@@ -25,14 +25,17 @@ export function upx2px (number, newDeviceWidth) {
if (number === 0) {
return 0
}
number = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth)
number = Math.floor(number + EPS)
if (number === 0) {
let result = (number / BASE_DEVICE_WIDTH) * (newDeviceWidth || deviceWidth)
if (result < 0) {
result = -result
}
result = Math.floor(result + EPS)
if (result === 0) {
if (deviceDPR === 1 || !isIOS) {
return 1
} else {
return 0.5
}
}
return number
return number < 0 ? -result : result
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册