mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(flexbox): justify content calculations
This commit is contained in:
@@ -1003,16 +1003,16 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
childRight = width - paddingRight;
|
childRight = width - paddingRight;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.FLEX_END:
|
case JustifyContent.FLEX_END:
|
||||||
childLeft = width - flexLine._mainSize + paddingRight;
|
childLeft = width - flexLine._mainSize - paddingRight;
|
||||||
childRight = flexLine._mainSize - paddingLeft;
|
childRight = flexLine._mainSize + paddingLeft;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.CENTER:
|
case JustifyContent.CENTER:
|
||||||
childLeft = paddingLeft + (width - flexLine._mainSize) / 2.0;
|
childLeft = paddingLeft + (width - insets.left - insets.right - flexLine._mainSize) / 2.0;
|
||||||
childRight = width - paddingRight - (width - flexLine._mainSize) / 2.0;
|
childRight = width - paddingRight - (width - insets.left - insets.right - flexLine._mainSize) / 2.0;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.SPACE_AROUND:
|
case JustifyContent.SPACE_AROUND:
|
||||||
if (flexLine._itemCount !== 0) {
|
if (flexLine._itemCount !== 0) {
|
||||||
spaceBetweenItem = (width - flexLine.mainSize) / flexLine._itemCount;
|
spaceBetweenItem = (width - insets.left - insets.right - flexLine.mainSize) / flexLine._itemCount;
|
||||||
}
|
}
|
||||||
childLeft = paddingLeft + spaceBetweenItem / 2.0;
|
childLeft = paddingLeft + spaceBetweenItem / 2.0;
|
||||||
childRight = width - paddingRight - spaceBetweenItem / 2.0;
|
childRight = width - paddingRight - spaceBetweenItem / 2.0;
|
||||||
@@ -1020,7 +1020,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
case JustifyContent.SPACE_BETWEEN:
|
case JustifyContent.SPACE_BETWEEN:
|
||||||
childLeft = paddingLeft;
|
childLeft = paddingLeft;
|
||||||
let denominator = flexLine.itemCount !== 1 ? flexLine.itemCount - 1 : 1.0;
|
let denominator = flexLine.itemCount !== 1 ? flexLine.itemCount - 1 : 1.0;
|
||||||
spaceBetweenItem = (width - flexLine.mainSize) / denominator;
|
spaceBetweenItem = (width - insets.left - insets.right - flexLine.mainSize) / denominator;
|
||||||
childRight = width - paddingRight;
|
childRight = width - paddingRight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1164,16 +1164,16 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
childBottom = height - paddingBottom;
|
childBottom = height - paddingBottom;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.FLEX_END:
|
case JustifyContent.FLEX_END:
|
||||||
childTop = height - flexLine._mainSize + paddingBottom;
|
childTop = height - flexLine._mainSize - paddingBottom;
|
||||||
childBottom = flexLine._mainSize - paddingTop;
|
childBottom = flexLine._mainSize + paddingTop;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.CENTER:
|
case JustifyContent.CENTER:
|
||||||
childTop = paddingTop + (height - flexLine._mainSize) / 2.0;
|
childTop = paddingTop + (height - insets.top - insets.bottom - flexLine._mainSize) / 2.0;
|
||||||
childBottom = height - paddingBottom - (height - flexLine._mainSize) / 2.0;
|
childBottom = height - paddingBottom - (height - insets.top - insets.bottom - flexLine._mainSize) / 2.0;
|
||||||
break;
|
break;
|
||||||
case JustifyContent.SPACE_AROUND:
|
case JustifyContent.SPACE_AROUND:
|
||||||
if (flexLine._itemCount !== 0) {
|
if (flexLine._itemCount !== 0) {
|
||||||
spaceBetweenItem = (height - flexLine._mainSize) / flexLine.itemCount;
|
spaceBetweenItem = (height - insets.top - insets.bottom - flexLine._mainSize) / flexLine.itemCount;
|
||||||
}
|
}
|
||||||
childTop = paddingTop + spaceBetweenItem / 2.0;
|
childTop = paddingTop + spaceBetweenItem / 2.0;
|
||||||
childBottom = height - paddingBottom - spaceBetweenItem / 2.0;
|
childBottom = height - paddingBottom - spaceBetweenItem / 2.0;
|
||||||
@@ -1181,7 +1181,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
case JustifyContent.SPACE_BETWEEN:
|
case JustifyContent.SPACE_BETWEEN:
|
||||||
childTop = paddingTop;
|
childTop = paddingTop;
|
||||||
let denominator = flexLine.itemCount !== 1 ? flexLine.itemCount - 1 : 1.0;
|
let denominator = flexLine.itemCount !== 1 ? flexLine.itemCount - 1 : 1.0;
|
||||||
spaceBetweenItem = (height - flexLine.mainSize) / denominator;
|
spaceBetweenItem = (height - insets.top - insets.bottom - flexLine.mainSize) / denominator;
|
||||||
childBottom = height - paddingBottom;
|
childBottom = height - paddingBottom;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user