mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Fix verticalAlignment center placement
This commit is contained in:
@ -448,6 +448,29 @@ export function test_GridLayout_ColumnWidth_when_4stars_and_width_110() {
|
||||
TKUnit.assertAreClose(cols[3].actualLength, 27, delta, "Column[3] actual length should be 27");
|
||||
}
|
||||
|
||||
export function test_GridLayout_margins_and_verticalAlignment_center() {
|
||||
|
||||
rootLayout.height = 200;
|
||||
rootLayout.width = 200;
|
||||
var btn = new helper.MyButton();
|
||||
btn.text = "btn";
|
||||
btn.height = 100;
|
||||
btn.width = 100;
|
||||
btn.marginBottom = 50;
|
||||
btn.marginRight = 50;
|
||||
rootLayout.addChild(btn);
|
||||
|
||||
TKUnit.waitUntilReady(function () {
|
||||
return btn.isLayoutValid;
|
||||
}, ASYNC);
|
||||
|
||||
var density = utils.layout.getDisplayDensity();
|
||||
var delta = Math.floor(density) !== density ? 1.1 : DELTA;
|
||||
|
||||
TKUnit.assertAreClose(btn.layoutTop, 25, delta * density, "vertical margins");
|
||||
TKUnit.assertAreClose(btn.layoutLeft, 25, delta * density, "horizontal margins");
|
||||
}
|
||||
|
||||
export function test_GridLayout_set_columns_in_XML() {
|
||||
var p = <page.Page>builder.parse("<Page><GridLayout columns=\"auto, *, 10*, 100 \"><Button/></GridLayout></Page>");
|
||||
var grid = <layout.GridLayout>p.content;
|
||||
|
@ -513,7 +513,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
break;
|
||||
|
||||
case enums.VerticalAlignment.center:
|
||||
childTop = top + ((bottom - top - childHeight) / 2) + (child.marginTop - child.marginBottom) * density;
|
||||
childTop = top + (bottom - top - childHeight + (child.marginTop - child.marginBottom) * density) / 2;
|
||||
break;
|
||||
|
||||
case enums.VerticalAlignment.bottom:
|
||||
@ -541,7 +541,7 @@ export class View extends proxy.ProxyObject implements definition.View {
|
||||
break;
|
||||
|
||||
case enums.HorizontalAlignment.center:
|
||||
childLeft = left + ((right - left - childWidth) / 2) + (child.marginLeft - child.marginRight) * density;
|
||||
childLeft = left + (right - left - childWidth + (child.marginLeft - child.marginRight) * density) / 2;
|
||||
break;
|
||||
|
||||
case enums.HorizontalAlignment.right:
|
||||
|
Reference in New Issue
Block a user