logical fixes
This commit is contained in:
@@ -596,12 +596,12 @@ function Element:layoutChildren()
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.flexDirection == FlexDirection.VERTICAL then
|
if self.flexDirection == FlexDirection.VERTICAL then
|
||||||
-- Position relative to parent origin
|
-- Position relative to parent origin along Y-axis (main axis)
|
||||||
child.x = self.x + (self.margin.left or 0)
|
child.x = self.x + (self.margin.left or 0)
|
||||||
child.y = self.y + currentPos
|
child.y = self.y + currentPos
|
||||||
|
|
||||||
-- Apply alignment to vertical axis (alignItems)
|
-- Apply alignment to cross axis (X-axis for vertical flex direction)
|
||||||
if self.alignItems == AlignItems.FLEX_START then
|
if self.alignItems == AlignItems.FLEX_START then
|
||||||
-- nothing
|
-- nothing
|
||||||
elseif self.alignItems == AlignItems.CENTER then
|
elseif self.alignItems == AlignItems.CENTER then
|
||||||
@@ -691,7 +691,7 @@ function Element:layoutChildren()
|
|||||||
-- This would be handled by the justifyContent logic already, so we'll keep existing behavior
|
-- This would be handled by the justifyContent logic already, so we'll keep existing behavior
|
||||||
end
|
end
|
||||||
|
|
||||||
currentPos = currentPos + (child.height or 0) + self.gap + (self.margin.top or 0) + (self.margin.bottom or 0)
|
currentPos = currentPos + (child.height or 0) + self.gap
|
||||||
else
|
else
|
||||||
-- Horizontal layout: position relative to parent origin
|
-- Horizontal layout: position relative to parent origin
|
||||||
child.x = self.x + currentPos + (self.margin.left or 0)
|
child.x = self.x + currentPos + (self.margin.left or 0)
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ function TestJustifyContent:testFlexEndJustifyContent()
|
|||||||
|
|
||||||
-- With flex-end, children should be positioned at the end of the container
|
-- With flex-end, children should be positioned at the end of the container
|
||||||
-- CSS behavior: children positioned at the end (rightmost for horizontal, bottommost for vertical)
|
-- CSS behavior: children positioned at the end (rightmost for horizontal, bottommost for vertical)
|
||||||
local totalWidth = child1.w + child2.w + window.gap -- child1.width + child2.width + gap
|
local totalWidth = child1.width + child2.width + window.gap -- child1.width + child2.width + gap
|
||||||
local containerWidth = window.w
|
local containerWidth = window.width
|
||||||
local expectedPosition = containerWidth - totalWidth
|
local expectedPosition = containerWidth - totalWidth
|
||||||
|
|
||||||
luaunit.assertAlmostEquals(child1.x, expectedPosition)
|
luaunit.assertAlmostEquals(child1.x, expectedPosition)
|
||||||
|
|||||||
Reference in New Issue
Block a user