mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-02 19:12:40 +08:00
fix(layout): prevent negative width/height values (#10616)
This commit is contained in:
@ -261,9 +261,14 @@ export class IOSHelper {
|
||||
|
||||
const left = layout.toDeviceIndependentPixels(position.left + insets.left);
|
||||
const top = layout.toDeviceIndependentPixels(position.top + insets.top);
|
||||
const width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right);
|
||||
const height = layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom);
|
||||
|
||||
let width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right);
|
||||
let height = layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom);
|
||||
if (width < 0) {
|
||||
width = 0;
|
||||
}
|
||||
if (height < 0) {
|
||||
height = 0;
|
||||
}
|
||||
return CGRectMake(left, top, width, height);
|
||||
}
|
||||
|
||||
|
||||
@ -82,6 +82,9 @@ export class ViewHelper {
|
||||
default:
|
||||
childTop = top + effectiveMarginTop;
|
||||
childHeight = bottom - top - (effectiveMarginTop + effectiveMarginBottom);
|
||||
if (childHeight < 0) {
|
||||
childHeight = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -112,6 +115,9 @@ export class ViewHelper {
|
||||
default:
|
||||
childLeft = left + effectiveMarginLeft;
|
||||
childWidth = right - left - (effectiveMarginLeft + effectiveMarginRight);
|
||||
if (childWidth < 0) {
|
||||
childWidth = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user