mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +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 left = layout.toDeviceIndependentPixels(position.left + insets.left);
|
||||||
const top = layout.toDeviceIndependentPixels(position.top + insets.top);
|
const top = layout.toDeviceIndependentPixels(position.top + insets.top);
|
||||||
const width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right);
|
let width = layout.toDeviceIndependentPixels(position.right - position.left - insets.left - insets.right);
|
||||||
const height = layout.toDeviceIndependentPixels(position.bottom - position.top - insets.top - insets.bottom);
|
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);
|
return CGRectMake(left, top, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,9 @@ export class ViewHelper {
|
|||||||
default:
|
default:
|
||||||
childTop = top + effectiveMarginTop;
|
childTop = top + effectiveMarginTop;
|
||||||
childHeight = bottom - top - (effectiveMarginTop + effectiveMarginBottom);
|
childHeight = bottom - top - (effectiveMarginTop + effectiveMarginBottom);
|
||||||
|
if (childHeight < 0) {
|
||||||
|
childHeight = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +115,9 @@ export class ViewHelper {
|
|||||||
default:
|
default:
|
||||||
childLeft = left + effectiveMarginLeft;
|
childLeft = left + effectiveMarginLeft;
|
||||||
childWidth = right - left - (effectiveMarginLeft + effectiveMarginRight);
|
childWidth = right - left - (effectiveMarginLeft + effectiveMarginRight);
|
||||||
|
if (childWidth < 0) {
|
||||||
|
childWidth = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user