mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
When relayout a node, preserve its frame origin.
This commit is contained in:
parent
9c51bde8e8
commit
075c39e398
@ -600,9 +600,27 @@ void ASDisplayNodeRespectThreadAffinityOfNode(ASDisplayNode *node, void (^block)
|
||||
} else {
|
||||
// This is the root node. Trigger a full measurement pass on *current* thread. Old constrained size is re-used.
|
||||
[self measureWithSizeRange:oldConstrainedSize];
|
||||
CGRect bounds = self.bounds;
|
||||
bounds.size = CGSizeMake(_layout.size.width, _layout.size.height);
|
||||
self.bounds = bounds;
|
||||
|
||||
CGSize oldSize = self.bounds.size;
|
||||
CGSize newSize = _layout.size;
|
||||
|
||||
if (! CGSizeEqualToSize(oldSize, newSize)) {
|
||||
CGRect bounds = self.bounds;
|
||||
bounds.size = newSize;
|
||||
self.bounds = bounds;
|
||||
|
||||
// Frame's origin must be preserved. Since it is computed from bounds size, anchorPoint
|
||||
// and position (see frame setter in ASDisplayNode+UIViewBridge), position needs to be adjusted.
|
||||
BOOL useLayer = (_layer && ASDisplayNodeThreadIsMain());
|
||||
CGPoint anchorPoint = (useLayer ? _layer.anchorPoint : self.anchorPoint);
|
||||
CGPoint oldPosition = (useLayer ? _layer.position : self.position);
|
||||
|
||||
CGFloat xDelta = (newSize.width - oldSize.width) * anchorPoint.x;
|
||||
CGFloat yDelta = (newSize.height - oldSize.height) * anchorPoint.y;
|
||||
CGPoint newPosition = CGPointMake(oldPosition.x + xDelta, oldPosition.y + yDelta);
|
||||
|
||||
useLayer ? _layer.position = newPosition : self.position = newPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user