fix: resize bug in retained mode
This commit is contained in:
@@ -108,6 +108,8 @@ function LayoutEngine.new(props, deps)
|
||||
childrenCount = 0,
|
||||
containerWidth = 0,
|
||||
containerHeight = 0,
|
||||
containerX = 0,
|
||||
containerY = 0,
|
||||
childrenHash = "",
|
||||
}
|
||||
|
||||
@@ -1180,6 +1182,10 @@ function LayoutEngine:recalculateUnits(newViewportWidth, newViewportHeight)
|
||||
end
|
||||
|
||||
-- Recalculate position if using viewport or percentage units
|
||||
-- Skip position recalculation for flex children (non-explicitly-absolute children with a parent)
|
||||
-- Their x/y is entirely controlled by the parent's layoutChildren() call
|
||||
local isFlexChild = self.element.parent and not self.element._explicitlyAbsolute
|
||||
if not isFlexChild then
|
||||
if self.element.units.x.unit ~= "px" then
|
||||
local parentWidth = self.element.parent and self.element.parent.width or newViewportWidth
|
||||
local baseX = self.element.parent and self.element.parent.x or 0
|
||||
@@ -1227,6 +1233,7 @@ function LayoutEngine:recalculateUnits(newViewportWidth, newViewportHeight)
|
||||
self.element.y = self.element.units.y.value * scaleY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Recalculate textSize if auto-scaling is enabled or using viewport/element-relative units
|
||||
if self.element.autoScaleText and self.element.units.textSize.value then
|
||||
@@ -1504,6 +1511,8 @@ function LayoutEngine:_canSkipLayout()
|
||||
local childrenCount = #self.element.children
|
||||
local containerWidth = self.element.width
|
||||
local containerHeight = self.element.height
|
||||
local containerX = self.element.x
|
||||
local containerY = self.element.y
|
||||
|
||||
-- Generate simple hash of children dimensions
|
||||
local childrenHash = ""
|
||||
@@ -1520,6 +1529,8 @@ function LayoutEngine:_canSkipLayout()
|
||||
cache.childrenCount == childrenCount
|
||||
and cache.containerWidth == containerWidth
|
||||
and cache.containerHeight == containerHeight
|
||||
and cache.containerX == containerX
|
||||
and cache.containerY == containerY
|
||||
and cache.childrenHash == childrenHash
|
||||
then
|
||||
return true -- Layout hasn't changed, can skip
|
||||
@@ -1529,6 +1540,8 @@ function LayoutEngine:_canSkipLayout()
|
||||
cache.childrenCount = childrenCount
|
||||
cache.containerWidth = containerWidth
|
||||
cache.containerHeight = containerHeight
|
||||
cache.containerX = containerX
|
||||
cache.containerY = containerY
|
||||
cache.childrenHash = childrenHash
|
||||
|
||||
return false -- Layout has changed, must recalculate
|
||||
|
||||
Reference in New Issue
Block a user